Skip to content

Commit 445ac1e

Browse files
authored
Merge pull request #56 from AboutJarry/master
Change the future.delay to Timer implementation, and make the ToastFu…
2 parents 64f0b0e + 6e4cf7e commit 445ac1e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/src/core/toast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ ToastFuture showToastWidget(
147147

148148
future = ToastFuture._(entry, onDismiss, key, animationDuration);
149149

150-
Future.delayed(duration, () {
150+
future.timer = Timer(duration, (){
151151
future.dismiss();
152152
});
153153

lib/src/core/toast_future.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class ToastFuture {
55
final OverlayEntry _entry;
66
final VoidCallback _onDismiss;
77
bool _isShow = true;
8+
Timer timer;
89
final GlobalKey<__ToastContainerState> _containerKey;
910
final Duration animationDuration;
1011

@@ -31,5 +32,8 @@ class ToastFuture {
3132
} else {
3233
_entry.remove();
3334
}
35+
36+
timer?.cancel();
37+
timer = null;
3438
}
3539
}

0 commit comments

Comments
 (0)