Skip to content

Instantly share code, notes, and snippets.

@GIfatahTH
Created May 28, 2020 09:42
Show Gist options
  • Save GIfatahTH/6dc73968c77222331bf5a9d01028c8e5 to your computer and use it in GitHub Desktop.
Save GIfatahTH/6dc73968c77222331bf5a9d01028c8e5 to your computer and use it in GitHub Desktop.
states_rebuilder_shopper
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Injector(
inject: [
// Inject the CatalogState.
Inject<CatalogState>(
// The starting state is CatalogInitialState
() => CatalogInitialState(CatalogRepository()),
),
//Inject CartState with initial state of empty items
Inject<CartState>(() => CartState(items: [])),
],
builder: (context) => MaterialApp(
title: 'Provider Demo',
theme: appTheme,
initialRoute: '/',
routes: {
'/': (context) => MyCatalog(),
'/cart': (context) => MyCart(),
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment