OnDidChangeCallback<ViewModel> typedef

OnDidChangeCallback<ViewModel> = void Function(ViewModel? previousViewModel, ViewModel viewModel)

A function that will be run on State change, after the build method.

This function is passed the previous and current ViewModel, and if distinct is true, it will only be called when the ViewModel changes.

This can be useful for running certain animations after the build is complete.

Note: Using a BuildContext inside this callback can cause problems if the callback performs navigation. For navigation purposes, please use an OnWillChangeCallback.

StoreConnector<int, int>(
  converter: (store) => store.state,
  onDidChange: (prev, vm) {
    if (prev != vm) {
      myScrollController.animateTo(200);
    }
  },
  builder: (context, vm) {
    return ListView.builder(
      controller: myScrollController,
      itemCount: vm,
      builder: (context, index) => Text('$index'),
    );
  },
);

Implementation

typedef OnDidChangeCallback<ViewModel> = void Function(
  ViewModel? previousViewModel,
  ViewModel viewModel,
);