File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change
1
+ import 'dart:async' ;
1
2
import 'dart:collection' ;
2
3
import 'dart:math' as math;
3
4
Original file line number Diff line number Diff line change @@ -20,13 +20,16 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
20
20
21
21
bool get _canSwipe => _currentIndex != null && ! widget.isDisabled;
22
22
23
+ StreamSubscription <ControllerEvent >? controllerSubscription;
24
+
23
25
@override
24
26
void initState () {
25
27
super .initState ();
26
28
27
29
_undoableIndex.state = widget.initialIndex;
28
30
29
- widget.controller? .events.listen (_controllerListener);
31
+ controllerSubscription =
32
+ widget.controller? .events.listen (_controllerListener);
30
33
31
34
_animationController = AnimationController (
32
35
duration: widget.duration,
@@ -65,6 +68,7 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
65
68
@override
66
69
void dispose () {
67
70
_animationController.dispose ();
71
+ controllerSubscription? .cancel ();
68
72
super .dispose ();
69
73
}
70
74
You can’t perform that action at this time.
0 commit comments