我正在使用flutter_redux和google_sign_in,我想在登录后从登录页面路由到另一个页面.
我正在使用调度LoggedInSuccessfully
操作的中间件来处理对Google的API调用.我知道我可以Navigator.pushNamed(context, "/routeName")
用于实际路由,但我是Flutter和Redux的新手,我的问题是我只是不知道在哪里调用它.
下面的代码是针对的GoogleAuthButtonContainer
,我猜测路由应该在哪里.这GoogleAuthButton
只是一个包含实际按钮和布局的简单小部件.
任何帮助表示感谢,谢谢!
@override
Widget build(BuildContext context) {
return new StoreConnector<AppState, _ViewModel>(
converter: _ViewModel.fromStore,
builder: (BuildContext context, _ViewModel vm) {
return new GoogleAuthButton(
buttonText: vm.buttonText,
onPressedCallback: vm.onPressedCallback,
);
},
);
}
}
class _ViewModel {
final String buttonText;
final Function onPressedCallback;
_ViewModel({this.onPressedCallback, this.buttonText});
static _ViewModel fromStore(Store<AppState> store) {
return new _ViewModel(
buttonText:
store.state.currentUser != null ? 'Log Out' : 'Log in with Google',
onPressedCallback: () {
if (store.state.currentUser != null) {
store.dispatch(new LogOut());
} else {
store.dispatch(new LogIn());
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1579 次 |
最近记录: |