Skip to content
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

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

Open
Abdullahfoysal opened this issue Sep 21, 2021 · 2 comments

Comments

@Abdullahfoysal
Copy link

Abdullahfoysal commented Sep 21, 2021

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)

@Abdullahfoysal Abdullahfoysal changed the title Navigator.of(context) .pushNamedAndRemoveUntil(LoginScreen.routeName, (route) => false);Unhandled Exception: Bad state: Cannot add new events after calling close Unhandled Exception: Bad state: Cannot add new events after calling close Sep 21, 2021
@luis-cruzt
Copy link

I'm having the same problem.

@chrisedg87
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants