dispose method

Future<void> dispose()

Stops referencing the element handle.

Returns a Future which completes when the object handle is successfully disposed.

Implementation

Future<void> dispose() async {
  if (_disposed) return;
  _disposed = true;

  if (remoteObject.objectId != null) {
    await executionContext.runtimeApi
        .releaseObject(remoteObject.objectId!)
        .catchError((_) {
      // Exceptions might happen in case of a page been navigated or closed.
      // Swallow these since they are harmless and we don't leak anything in this case.
    });
  }
}