updateBlocOnChange method

void updateBlocOnChange({
  1. required dynamic change(),
  2. required List tracker(),
})
inherited

Updates the Bloc after calling change if the value returned by tracker changes.

Slightly less efficient than writing the code yourself, but reduces boilerplate.

Note the change has to be a synchronous call. If change returns a future, use updateBlocOnFutureChange instead.

Implementation

void updateBlocOnChange({
  required dynamic Function() change,
  required List<dynamic> Function() tracker,
}) {
  final track = tracker();

  change();

  if (!_equality(track, tracker())) {
    updateBloc();
  }
}