-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dispose method needs to cancel timer #3
Comments
Thank you for comment. |
I finished it. Please check latest version. |
Looks good! Thanks again for making this package :) |
close |
still buggy in latest release 2.0.0 VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Cannot add new events after calling close |
Hi,
Thanks for the great plugin!
Just noticed one small issue in the dispose method. If the timer is started and the widget is then disposed before the timer is stopped, Timer.periodic() will still try to add events to the now closed PublishSubjects. See the error below:
I/flutter (21245): I/flutter (21245): #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:249:24) I/flutter (21245): #1 Subject._add package:rxdart/…/subjects/subject.dart:141 I/flutter (21245): #2 Subject.add package:rxdart/…/subjects/subject.dart:135 I/flutter (21245): #3 StopWatchTimer._handle package:stop_watch_timer/stop_watch_timer.dart:185 I/flutter (21245): #4 _rootRunUnary (dart:async/zone.dart:1198:47) I/flutter (21245): #5 _CustomZone.runUnary (dart:async/zone.dart:1100:19) I/flutter (21245): #6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7) I/flutter (21245): #7 _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1042:26) I/flutter (21245): #8 _rootRunUnary (dart:async/zone.dart:1206:13) I/flutter (21245): #9 _CustomZone.runUnary (dart:async/zone.dart:1100:19) I/flutter (21245): #10 _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1026:26) I/flutter (21245): #11 _Closure.call (dart:core-patch/function.dart) I/flutter (21245): #12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19) I/flutter (21245): #13 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5) I/flutter (21245): #14 _Closure.call (dart:c I/flutter (21245): Error caught by Crashlytics plugin <recordError>: I/flutter (21245): Bad state: Cannot add new events after calling close
I fixed it locally by calling _timer.close(); in the first line of the dispose() method.
The text was updated successfully, but these errors were encountered: