Skip to content

Commit 955631a

Browse files
gf_toast timer dispose
1 parent 1fca4ce commit 955631a

File tree

2 files changed

+3
-166
lines changed

2 files changed

+3
-166
lines changed

lib/components/toast/gf_toast.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class GFToast extends StatefulWidget {
6565
class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
6666
late AnimationController animationController, fadeAnimationController;
6767
late Animation<double> animation, fadeAnimation;
68+
Timer? timer;
6869
bool hideToast = false;
6970

7071
@override
@@ -85,7 +86,7 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
8586
begin: 0,
8687
end: 1,
8788
).animate(fadeAnimationController);
88-
Timer(widget.duration, () {
89+
timer = Timer(widget.duration, () {
8990
if (mounted) {
9091
fadeAnimationController.forward();
9192
}
@@ -110,6 +111,7 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
110111
void dispose() {
111112
animationController.dispose();
112113
fadeAnimationController.dispose();
114+
timer?.cancel();
113115
super.dispose();
114116
}
115117

test/toast_test.dart

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)