satudora-dev / bloc_sample

bloc pattern sample code
0 stars 0 forks source link

複雑なUIがあるPageの中でのBLoCの使い方 #14

Open gakuh opened 5 years ago

gakuh commented 5 years ago

WHY

WHAT

REF

gakuh commented 5 years ago

ここを見ると、一番大元のWidgetをbuildするときにbloc_providerを呼んでいる https://github.com/mono0926/bloc_provider/blob/master/example/complex/lib/main.dart#L25

class App extends StatelessWidget {
  const App();
  @override
  Widget build(BuildContext context) {
    return BlocProviderTree(
      blocProviders: [
        CatalogProvider(),
        CartProvider(),
      ],
      child: MaterialApp(
        title: 'Bloc Complex',
        theme: appTheme,
        home: const MyHomePage(),
        routes: {
          BlocCartPage.routeName: (context) => const BlocCartPage(),
        },
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {