Describe the bug
After successfully registering a new user, the form is unable to access AuthenticationBloc.
bloc/examples/flutter_firebase_login/lib/register/register_form.dart
if (state.isSuccess) {
BlocProvider.of<AuthenticationBloc>(context).dispatch(LoggedIn());
Navigator.of(context).pop();
}
This is because navigating to this page from the login page has result in the loss of the current context.
https://github.com/felangel/bloc/blob/master/examples/flutter_firebase_login/lib/login/create_account_button.dart
Navigator.of(context).push(
MaterialPageRoute(builder: (context) {
return RegisterScreen(userRepository: _userRepository);
}),
);
To Reproduce
Steps to reproduce the behavior:
Expected behavior
After registering user should see the home page
Hi @nicktran29 馃憢
Thanks for opening an issue!
Unfortunately, I was unable to reproduce the issue you're describing. There shouldn't be a problem accessing the AuthenticationBloc because it is provided above the MaterialApp making it globally accessible (even across routes).
Can you please confirm that you're running the example app without any local modifications?
Closing for now but feel free to comment with additional information and I'm happy to continue the conversation 馃憤
Hi @felangel,
Thanks for looking into this.
My issue was I provided the bloc inside MaterialApp. So I guess my question is what do I need to do in order to access a bloc provided to a widget that I'm navigating away from?
Cheers.
Don't mind me I found the way in your recipe. Great lib and documentation! https://felangel.github.io/bloc/#/recipesflutterblocaccess
Most helpful comment
Don't mind me I found the way in your recipe. Great lib and documentation! https://felangel.github.io/bloc/#/recipesflutterblocaccess