【发布时间】:2019-12-30 21:17:20
【问题描述】:
我有这两种方法:
Future<Either<Failure, WorkEntity>> getWorkEntity({int id})
和
Future<Either<Failure, WorkEntity>> updateWorkEntity({int id, DateTime executed})
它们都经过测试并按预期工作。然后我有了结合两者的第三种方法:
Future<Either<Failure, WorkEntity>> call(Params params) async {
final workEntityEither = await repository.getWorkEntity(id: params.id);
return await workEntityEither.fold((failure) => Left(failure), (workEntity) => repository.updateWorkEntity(id: workEntity.id, executed: DateTime.now()));
}
这个方法不起作用,它总是返回null。我怀疑这是因为我不知道在折叠方法中返回什么。如何让它发挥作用?
谢谢
索伦
【问题讨论】: