chrisedg87 / flutter_rounded_loading_button

A simple implementation of an animated loading button widget for Flutter
MIT License
339 stars 87 forks source link

Unhandled Exception: Bad state: Cannot add new events after calling close #48

Open Abdullahfoysal opened 3 years ago

Abdullahfoysal commented 3 years ago

My code: _btnController.start(); var logoutData = await HttpService().logOut(api, body); if (logoutData != null) { _btnController.stop(); Navigator.of(context) .pushNamedAndRemoveUntil(LoginScreen.routeName, (route) => false); }

errors:
[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: Bad state: Cannot add new events after calling close

0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24)

1 Subject._add (package:rxdart/src/subjects/subject.dart:141:17)

2 Subject.add (package:rxdart/src/subjects/subject.dart:135:5)

3 _StreamSinkWrapper.add (package:rxdart/src/subjects/subject.dart:167:13)

4 RoundedLoadingButtonState._reset (package:rounded_loading_button/rounded_loading_button.dart:305:17)

luis-cruzt commented 3 years ago

I'm having the same problem.

chrisedg87 commented 3 years ago

You would get this error if one of the controller action methods is called after the widget is removed from the stack. My guess in the example would be that the stop() call is probably unnecessary as the widget is removed in the next line.