我碰到下面的代码示例从flutter_redux示例代码。 有一个很难理解为什么factory SearchState.initial()
与返回new
关键字,而factory SearchState.loading()
和factory SearchState.error()
没有。
class SearchState {
final SearchResult result;
final bool hasError;
final bool isLoading;
SearchState({
this.result,
this.hasError = false,
this.isLoading = false,
});
factory SearchState.initial() =>
new SearchState(result: SearchResult.noTerm());
factory SearchState.loading() => SearchState(isLoading: true);
factory SearchState.error() => SearchState(hasError: true);
}
刚刚发现达特语言导游不太这种情况有帮助,以及飞镖语言规范是太晦涩。