Bloc: MultiBlocBuilder

Created on 23 Jul 2019  路  2Comments  路  Source: felangel/bloc

Is your feature request related to a problem? Please describe.
I want better readability for the nested bloc builders

Describe the solution you'd like
I think there should be MultiBlocBuildersame like MultiBlocListener

Describe alternatives you've considered
An alternative solution could be RepositoryBlocBuilderwhich take multi listeners and multi bloc builders
sample:

RepositoryBlocBuilder (
        listeners: [
          BlocListener<ConfigBloc, ConfigState>(
            listener: (BuildContext context, ConfigState state) {
              if (state is ConfigFailedState) {
                showSnackBar(state.configModel.message);
              }
            },
          ),
          BlocListener<LoginBloc, LoginState>(
            listener: (BuildContext context, LoginState state) {
              if (state is LoginStoredState) {
                Navigator.of(context).pushReplacementNamed(PAGE_DASHBOARD);
              } else if (state is LoginFailedState) {
                showSnackBar(state.loginModel.message);
              }
            },
          ),
        ],
builders:[BlocBuilder<ConfigBloc, ConfigState>(
                builder: (BuildContext context, ConfigState configState) {
                  return _buildLoginButton(
                      configState: configState, loginState: loginState);
                }),
 BlocBuilder<LoginBloc, LoginState>(
                builder: (BuildContext context, LoginState loginState) {
                  return _buildLoginButton(
                      configState: configState, loginState: loginState);
                })]
)
question

Most helpful comment

Hi @amreniouinnovent 馃憢
Thanks for opening an issue!

I will create an official RFC (request for change) over the next few days for MultiBlocBuilder and let the community decide if they want it 馃憤

Regarding RepositoryBlocBuilder, I don't think it is clear what this widget is supposed to be used for and if there is a MultiBlocBuilder and MultiBlocListener, I would argue there is probably less of a need to have a widget that combines them.

All 2 comments

Hi @amreniouinnovent 馃憢
Thanks for opening an issue!

I will create an official RFC (request for change) over the next few days for MultiBlocBuilder and let the community decide if they want it 馃憤

Regarding RepositoryBlocBuilder, I don't think it is clear what this widget is supposed to be used for and if there is a MultiBlocBuilder and MultiBlocListener, I would argue there is probably less of a need to have a widget that combines them.

@felangel just alternative style never mind
Thank you for your hard effort

Was this page helpful?
0 / 5 - 0 ratings