We recently updated from version 20.0.2 to version 23.2.0 of async_redux on Flutter Web, and we noticed that with this update now every time a variable inside the state that is used in the viewmodel in a StoreConnector page (StatelessWidget) is updated, the initState of the child (StatefulWidget) is always called and no longer the didUpdateWidget.
class ModalContainer extends StatelessWidget {
ModalContainer() : super(key: UniqueKey());
@override
Widget build(BuildContext context) {
return StoreConnector<AppState, ViewModel>(
vm: () => Factory(this),
builder: (BuildContext context, ViewModel vm) {
return StatefulWidgetModal(
vm.stateVariable,
);
},
);
}
}
class ViewModel extends Vm {
final List<stateVariable>? stateVariable;
ViewModel({
this.stateVariable,
}) : super(equals: <Object?>[stateVariable]);
}
class Factory extends VmFactory<AppState, ModalContainer, ViewModel> {
Factory(ModalContainer connector) : super(connector);
@override
ViewModel fromStore() => ViewModel(
stateVariable: state.testState.stateVariable,
);
}
After we call this action (DataAction), in the StatefulWidgetModal widget the initState now is always called. Before the update the didUpdateWidget was called.
class DataAction extends ReduxAction<AppState> {
DataAction();
@override
Future<AppState?> reduce() async {
return state.copy(
testState: state.testState.copyWith(
stateVariable: "updateValue",
));
}
}
We searched through old issues and changelogs but we found nothing about this change/issue.
I also tried adding the flags: distinct: true. But as soon as an action is called the whole widget is rebuilt even if the state is not updated.