feat: fix some bugs.

This commit is contained in:
2022-01-18 18:58:18 +08:00
parent a088f857e8
commit c567122d84
5 changed files with 15 additions and 8 deletions
+10 -2
View File
@@ -287,6 +287,8 @@ class _CherryToastState extends State<CherryToast> with TickerProviderStateMixin
late Animation<Offset> offsetAnimation;
late AnimationController slideController;
late BoxDecoration toastDecoration;
bool _dismissed = false;
@override
void initState() {
@@ -311,7 +313,10 @@ class _CherryToastState extends State<CherryToast> with TickerProviderStateMixin
Timer(this.widget.toastDuration, () {
slideController.reverse();
Timer(this.widget.animationDuration, () {
if (mounted) Navigator.pop(context);
if (mounted && !_dismissed) {
_dismissed = true;
Navigator.pop(context);
}
});
});
}
@@ -463,7 +468,10 @@ class _CherryToastState extends State<CherryToast> with TickerProviderStateMixin
onTap: () {
slideController.reverse();
Timer(this.widget.animationDuration, () {
if (mounted) Navigator.pop(context);
if (mounted && !_dismissed) {
_dismissed = true;
Navigator.pop(context);
}
});
},
child: Icon(Icons.close, color: Colors.grey[500], size: CLOSE_BUTTON_SIZE),