【发布时间】:2020-11-19 18:24:58
【问题描述】:
我在看this example
@immutable
class UserState {
final bool isLoading;
final LoginResponse user;
UserState({
@required this.isLoading,
@required this.user,
});
factory UserState.initial() {
return new UserState(isLoading: false, user: null);
}
UserState copyWith({bool isLoading, LoginResponse user}) {
return new UserState(
isLoading: isLoading ?? this.isLoading, user: user ?? this.user);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is UserState &&
runtimeType == other.runtimeType &&
isLoading == other.isLoading &&
user == other.user;
@override
int get hashCode => isLoading.hashCode ^ user.hashCode;
}
hashCode 与此有什么关系?这有什么用途? (我已经缩短了代码,因为我收到了我发布的大多数代码的 stackoverflow 错误)
谢谢
【问题讨论】:
标签: flutter redux flutter-redux