dispose method Null safety

  1. @override
Future<void> dispose()
override

Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener and removeListener will throw after the object is disposed).

This method should only be called by the object's owner.

Implementation

@override
Future<void> dispose() async {
  if (_creatingCompleter != null) {
    await _creatingCompleter!.future;
    if (!_isDisposed) {
      _isDisposed = true;
      _timer?.cancel();
      await _eventSubscription?.cancel();
      await _videoPlayerPlatform.dispose(_textureId);
    }
    _lifeCycleObserver.dispose();
  }
  _isDisposed = true;
  super.dispose();
}