Describe the bug
I used Flutter_bloc for authentication with firebaseAuth
. And now I used Flutter_bloc for Changing Theme at run-time
and these two blocBuilder exists in main class as shown bellow:
Code:
@override
Widget build(BuildContext context) {
return BlocBuilder(
bloc: changeThemeBloc,
builder: (BuildContext context, ChangeThemeState state) {
return MaterialApp(
theme: state.themeData,
home: BlocBuilder<AuthenticationBloc, AuthenticationState>(
builder: (context, state) {
if (state is Uninitialized) {
return SplashScreen();
}
if (state is Unauthenticated) {
return LoginScreen(userRepository: _userRepository);
}
if (state is Authenticated) {
return HomeBase(name: state.displayName);
}
return null;
},
),
);
},
);
}
As shown I used bloc inside another bloc is there any problem ?
And thanks for your efforts.
it's ok I think, since they are different streams, but be aware that when the Theme bloc changes state, it will rebuild the entire widget tree (which is the intended behavior I guess? )
Hi @gtxgat 馃憢
Thanks for opening an issue!
As @bigworld12 mentioned, it's perfectly fine to nest BlocBuilders so long as you are intending the child of each BlocBuilder to re-render on each state change 馃憤