Skip to content

Commit 974c4e3

Browse files
authored
Correct dispose of flutter switch widget
Hi, first of all, thanks for publishing this package, it is awesome. In a project that I use it, I was getting an exception when I tried to force the widget to rebuilt. The exception was exception: disposed with an active ticker. The solution is to dispose the animation controller, so there you go.
1 parent 6195f64 commit 974c4e3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/flutter_switch.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class _FlutterSwitchState extends State<FlutterSwitch>
5656
CurvedAnimation(parent: _animationController, curve: Curves.linear),
5757
);
5858
}
59+
60+
@override
61+
void dispose() {
62+
_animationController.dispose();
63+
super.dispose();
64+
}
5965

6066
@override
6167
Widget build(BuildContext context) {

0 commit comments

Comments
 (0)