title: Flutter - How to architect multiple nested BLoC?
body: <p>Suppose there is a top-level BLoC called PreferenceBloc, and inside that BLoC is another BLoC called PageBloc. If the logic inside PageBloc requires on a value stream from PreferenceBloc (i.e., create a new page needs to know page configuration now), how should I architect this?</p>
  
  <p>Code sample:</p>
  
  <pre><code>class PreferencesBloc{
    final preferencesService=PreferencesService();
  
    // Output interfaces of Bloc
    ValueObservable&lt;String&gt; get mainDir =&gt; _mainDir.distinct().shareValue(seedValue: '/');
    final _mainDir = BehaviorSubject&lt;String&gt;(seedValue: '/');
  
    // Input interfaces of Bloc...
    // .........
  }
  class PageBloc{
    final List&lt;PageInfo&gt; _pageInfos=&lt;PageInfo&gt;[];
    // Output interfaces of Bloc...
    // .........
  
    // Input interfaces of Bloc...
    Sink&lt;int&gt; get pageCreation =&gt; _pageCreationController.sink;
    final _pageCreationController = StreamController&lt;int&gt;();
  
    pageBloc(){
      _pageCreationController.stream.listen(_handleCreation);
    }
    void _handleCreation(int pos){
      _pageInfo.insert(pos, PageInfo('I need the mainDir here!')); //Need info from PreferencesBloc!!!
    }
  }
  
  class PreferencesProvider extends InheritedWidget{
    final PreferencesBloc preferencesBloc;
    //...
  }
  class PageProvider extends InheritedWidget{
    final PageBloc pageBloc;
    //...
  }
  
  
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return PreferencesProvider(
        child: PageProvider(
          child: MaterialApp(
            home: Scaffold(
              body: Text("test"),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>Edit: To sum up, it is convenient to communicate between Bloc and widget in flutter, but is there a good way to communicate between Bloc and Bloc?</p>