I'm using redux and bloc together. I have a edit profile screen and I get initial value from redux state and then change values in bloc. But when my bloc state changed, redux state change too without dispatching action. I want to change redux state when user submit edited values. here is my first part of build method:
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);
...
and my widget to show and change image:
ImageSelect(
onSelect: (img) => _bloc.add(
EditUserProfileImageChanged(imgSrc: img),
),
child: Avatar(imgSrc: state.userProfile.avatar),
),
and my bloc:
if (event is EditUserProfileImageChanged) {
UserProfile newUserProfile = state.userProfile;
yield EditUserProfileBeforeTotalChanged();
newUserProfile.avatar = event.imgSrc;
yield EditUserProfileTotalState(userProfile: newUserProfile);
}
here when I change avatar without saving, other places I use avatar change too.