felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.79k stars 3.39k forks source link

Bloc and work with settings #675

Closed FetFrumos closed 4 years ago

FetFrumos commented 4 years ago

I'm new to flutter. I study documentation and examples by BLOC.
I'm studying this example now - flutter_timer. Now this example working with static value for time(60), I want add time value in app settings. But I don’t know how to create the right architecture(bloc) for this. I try this: -use MultiBlocProvider, like flutter_weather example

   MultiBlocProvider(
   providers: [
     BlocProvider<SettingsBloc>(
       builder: (context) => SettingsBloc(),
     )...

but how use my SettingsBloc with TimerBloc?

How does TimerBloc know that the meaning has changed(SettingsBloc)? I need an example of the “right architecture” for this.

I will be grateful for any advice.

felangel commented 4 years ago

Hi @FetFrumos 👋 Thanks for opening an issue!

You might not need a SettingsBloc because if you have a global TimerBloc which you provide at the root of your application, then you can add a TimerDurationChanged(Duration duration) event and update the state of your TimerBloc accordingly.

Hope that helps 👍