我正在用flutter_bloc编写登录应用程序,我面临着一些问题!
I/颤振(23617):来自Api Provider:f6c3e63f1a95b0709d2b70075d0d592e0c4a5f85 I/颤振(23617)的键: f6c3e63f1a95b0709d2b70075d0d592e0c4a5f85 ->我已经在SharedPrefrences I/颤振(23617)中保存了密钥:过渡{ currentState: LoginState {I/颤振(23617):isUsernameValid:真,I/颤振(23617):isPasswordValid:真,I/颤振(23617):isSubmitting:真,I/颤振(23617):isSuccess: false,I/颤振(23617):isFailure: false,I/颤振(23617):},事件: LoginWithCredentialsPressed {用户名: yelinaung,密码: asdfghjkl12345 },nextState: LoginState {i/颤振(23617):isUsernameValid:真,i/颤振(23617):isPasswordValid:真,i/颤振(23617):isSubmitting:假,i/颤振(23617):isSuccess: false,<-i/颤振(23617):isFailure:真,i/颤振(23617):}‘ 2.I希望在登录返回键时导航到家。我想问题就在@override Stream<LoginState> mapEventToState( LoginEvent event, ) async\* { if (event is LoginWithUserNamePass) { yield\* \_mapLoginWithUserNamePass( username: event.username, password: event.password); } } Stream<LoginState> \_mapLoginWithUserNamePass( {String username, String password}) async\* { yield LoginState.loading();----> try { ##### final String key = await \_apiLoader.doLogin(username, password);##### problem here? ##### \_authenticationBloc.dispatch(LoggedInNow(key));####### problem here? yield LoginState.success(); } catch (\_) { yield LoginState.failure(); } } }
的login_bloc
如果删除上面的state-success,则返回
true。
3。如果我退出应用程序并重新输入它,它将显示在下面的Authenticated...as
I/flutter (23617): Authenticated { key: f6c3e63f1a95b0709d2b70075d0d592e0c4a5f85 }
I/flutter (23617): LoggedIn```
and navigate to home screen ...
>Can someone solve this problem,thank .
发布于 2019-09-17 10:02:14
解决了。我变了
final String key = await _apiLoader.doLogin(username, password);
_authenticationBloc.dispatch(LoggedInNow(key));####### problem
here?
yield LoginState.success();
}```
TO====>
```try {
await _apiLoader.doLogin(username, password);
yield LoginState.success();
}
另一个问题是_apiLoader.dologin is not Future<void> or it return value
im白痴;)
https://stackoverflow.com/questions/57971638
复制相似问题