close method

  1. @mustCallSuper
  2. @override
Future<void> close()
inherited

Closes the event and state Streams. This method should be called when a Bloc is no longer needed. Once close is called, events that are added will not be processed. In addition, if close is called while events are still being processed, the Bloc will finish processing the pending events.

Implementation

@mustCallSuper
@override
Future<void> close() async {
  await _eventController.close();
  for (final emitter in _emitters) {
    emitter.cancel();
  }
  await Future.wait<void>(_emitters.map((e) => e.future));
  await Future.wait<void>(_subscriptions.map((s) => s.cancel()));
  return super.close();
}