我正在使用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()); } }); } }
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。