dispose method

void dispose()

Call this method to signal the ImageStreamCompleter that it can now be disposed when its last listener drops.

This method must only be called once per object.

Implementation

void dispose() {
  assert(_completer != null);
  assert(_completer!._keepAliveHandles > 0);
  assert(!_completer!._disposed);

  _completer!._keepAliveHandles -= 1;
  _completer!._maybeDispose();
  _completer = null;
  // TODO(polina-c): stop duplicating code across disposables
  // https://github.com/flutter/flutter/issues/137435
  if (kFlutterMemoryAllocationsEnabled) {
    FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
  }
}