Last active
February 11, 2019 18:11
-
-
Save marcinOz/ae582ea79cd1e4eb6f7f9d3ea7c5ccd9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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