问题描述
我将此方法作为我的存储库:
Future<Either<Exceptions,bool>> userRegister(FormData formData) async {
try {
final response = await _mourdakApi.userRegister(formData);
bool _isSuccesed;
if (response.statusCode == 200)
_isSuccesed = true;
else
_isSuccesed = false;
return Right(_isSuccesed);
} catch (e) {
return Left(
Exceptions(
message: e.toString(),),);
}
}
现在我想在这里使用折叠方法:
final failedOrResult = _mourdakRepository.userRegister(event.formData);
return failedOrResult.fold(
(exception) => UserExceptionState(exception.message),(isSuccesed) => UserRegisterState(isSuccesed));
但是我收到了这个错误:
The method 'fold' isn't defined for the type 'Future'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)