dispose method Null safety

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

Disposes the Android view.

The AndroidViewController object is unusable after calling this. The identifier of the platform view cannot be reused after the view is disposed.

Implementation

@override
Future<void> dispose() async {
  if (_state == _AndroidViewState.creating || _state == _AndroidViewState.created) {
    await _sendDisposeMessage();
  }
  _platformViewCreatedCallbacks.clear();
  _state = _AndroidViewState.disposed;
  PlatformViewsService._instance._focusCallbacks.remove(viewId);
}