filiph / state_experiments

Companion repository to the "Build reactive mobile apps in Flutter" talk
https://www.youtube.com/watch?v=RS36gBEp8OI
910 stars 134 forks source link

What's another way mechanism to pass blocs down the tree? #10

Open junjizhi opened 6 years ago

junjizhi commented 6 years ago

In your bloc_complex example, you force the bloc provider to form a tree, even though they may not be...

Widget build(BuildContext context) {
    // Here we're providing the catalog component ...
    return CatalogProvider(
      catalog: catalog,
      // ... and the cart component via InheritedWidget like so.
      // But BLoC works with any other mechanism, including passing
      // down the widget tree.
      child: CartProvider(
      //...

I understand it's implemented this way because we have to make provider as an ancestor of the children widget. What's an alternative implementation?