Flutter 颤振重复状态已更改,无需调度操作
我正在一起使用redux和bloc。 我有一个编辑配置文件屏幕,我从redux状态获取初始值,然后在bloc中更改值。 但当我的集团状态发生变化时,redux状态也会发生变化,而无需调度操作。 我想在用户提交编辑的值时更改redux状态。 以下是构建方法的第一部分:Flutter 颤振重复状态已更改,无需调度操作,flutter,redux,bloc,flutter-redux,Flutter,Redux,Bloc,Flutter Redux,我正在一起使用redux和bloc。 我有一个编辑配置文件屏幕,我从redux状态获取初始值,然后在bloc中更改值。 但当我的集团状态发生变化时,redux状态也会发生变化,而无需调度操作。 我想在用户提交编辑的值时更改redux状态。 以下是构建方法的第一部分: return StoreConnector<AppState, Store<AppState>>( converter: (store) => store, builder: (context,
return StoreConnector<AppState, Store<AppState>>(
converter: (store) => store,
builder: (context, store) {
return Scaffold(
appBar: appBar,
body: BlocProvider(
create: (context) => EditUserProfileBloc(
editEditUserProfileRepository: repository,
)..add(
EditUserProfileScreenLoaded(
userProfile: store.state.userProfile,
),
),
child: BlocListener<EditUserProfileBloc, EditUserProfileState>(
listener: (context, state) async {},
child: BlocBuilder<EditUserProfileBloc, EditUserProfileState>(
builder: (context, state) {
_bloc = BlocProvider.of<EditUserProfileBloc>(context);
...
我的集团:
if (event is EditUserProfileImageChanged) {
UserProfile newUserProfile = state.userProfile;
yield EditUserProfileBeforeTotalChanged();
newUserProfile.avatar = event.imgSrc;
yield EditUserProfileTotalState(userProfile: newUserProfile);
}
在这里,当我在不保存的情况下更改头像时,我使用头像的其他地方也会更改
if (event is EditUserProfileImageChanged) {
UserProfile newUserProfile = state.userProfile;
yield EditUserProfileBeforeTotalChanged();
newUserProfile.avatar = event.imgSrc;
yield EditUserProfileTotalState(userProfile: newUserProfile);
}