updateBlocOnFutureChange method

Future<void> updateBlocOnFutureChange({
  1. required Future 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.

Unlike the similar updateBlocOnChange, this supports the change function returning a super.

Implementation

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

  await change();

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