Page-View pattern

PHOTO EMBED

Thu Oct 06 2022 11:22:44 GMT+0000 (Coordinated Universal Time)

Saved by @alefl10 #dart #flutter #bloc #page #view

// PAGE
class MyPage extends StatelessWidget {
  const MyPage({super.key});
 
  static String path = 'my';
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // Inject Bloc(s)
      body: BlocProvider(
        create: (context) => MyBloc(dependency: context.read<Dependency>()),
        // VIEW
        // MyView, and all its nested child Widgets, will have access to MyBloc
        child: const MyView(),
      ),
    );
  }
}
content_copyCOPY