Created
November 16, 2019 04:20
-
-
Save juliuscanute/971d6bb5c148c5aaa329c8219d7a44f6 to your computer and use it in GitHub Desktop.
[Define routes] #navigation #dart #redux #flutter #push #getarguments
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
@override | |
Widget build(BuildContext context) { | |
Map args = ModalRoute.of(context).settings.arguments; | |
var _email; | |
if (args != null) { | |
_email = args["email"]; | |
} | |
} |
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
class _ViewModel { | |
final Store<LoginAppState> store; | |
const _ViewModel({this.store}); | |
static _ViewModel fromStore(Store<LoginAppState> store) { | |
return _ViewModel(store: store); | |
} | |
void signUp() { | |
store.dispatch(NavigateToAction.push('/signup')); | |
} | |
void forgotPassword() { | |
store.dispatch(NavigateToAction.push('/forgot')); | |
} | |
} |
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
@override | |
Widget build(BuildContext context) { | |
return StoreProvider<LoginAppState>( | |
store: store, | |
child: MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Time Sheet', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
navigatorKey: NavigatorHolder.navigatorKey, | |
routes: { | |
'/home': (BuildContext context) => Scaffold( | |
body: HomeScreen(), | |
), | |
'/login': (BuildContext context) => Scaffold( | |
body: LoginScreen(), | |
), | |
'/signup': (BuildContext context) => Scaffold( | |
body: SignUpScreen(), | |
), | |
'/forgot': (BuildContext context) => Scaffold( | |
body: ForgotPasswordScreen(), | |
), | |
}, | |
home: Scaffold( | |
body: LoadScreen(), | |
)), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment