dispose method

  1. @override
Future<Null> dispose()

Dispose of the object, cleaning up to prevent memory leaks.

Implementation

@override
Future<Null> dispose() {
  if (isDisposedOrDisposing) {
    return didDispose;
  }
  _isDisposing = true;

  var disposeFuture = _disposer != null
      ? (_disposer!() ?? Future.value())
      : Future<dynamic>.value();
  _disposer = null;

  return disposeFuture.then((_) {
    _disposer = null;
    _didDispose.complete();
    _isDisposing = false;
  });
}