在转向空安全之后,我很难了解如何重构我的一些代码。
我有一个看起来像这样的方法
final Reducer<Exception> _errorReducer = combineReducers<Exception>([
TypedReducer<Exception, ErrorOccurredAction>(_errorOccurredReducer),
TypedReducer<Exception, ErrorHandledAction>(_errorHandledReducer),
]);
Exception _errorOccurredReducer(Exception _, ErrorOccurredAction action) {
return action.exception;
}
Exception _errorHandledReducer(Exception _, ErrorHandledAction action) {
return null;
}
既然error
被初始化为null,我怎样才能允许一个null返回能够将它设置回null。
最近介绍了静态类型的工作流程,所以我正在学习。
注意:如果有更好的做法来处理我想要实现的目标,请记住分享它。