Skip to content

Instantly share code, notes, and snippets.

@marcinOz
Last active February 11, 2019 18:11
Show Gist options
  • Save marcinOz/ae582ea79cd1e4eb6f7f9d3ea7c5ccd9 to your computer and use it in GitHub Desktop.
Save marcinOz/ae582ea79cd1e4eb6f7f9d3ea7c5ccd9 to your computer and use it in GitHub Desktop.
void main() => runApp(MyApp());
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
class MyApp extends StatelessWidget {
final store = Store<AppState>(appReducer,
initialState: AppState.loading(),
middleware: createNavigationMiddleware());
MaterialPageRoute _getRoute(RouteSettings settings) {
switch (settings.name) {
case AppRoutes.home:
return MainRoute(HomePage(), settings: settings);
case AppRoutes.addGame:
return FabRoute(NewGame(), settings: settings);
default:
return MainRoute(StubScreen(), settings: settings);
}
}
@override
Widget build(BuildContext context) {
return StoreProvider(
store: store,
child: MaterialApp(
navigatorKey: navigatorKey,
navigatorObservers: [routeObserver],
title: AppLocalizations.appTitle,
theme: theme,
onGenerateRoute: (RouteSettings settings) => _getRoute(settings),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment