hide method

Future<void> hide()

Hides this system context menu.

If this hasn't been shown, or if another instance has hidden this menu, does nothing.

Currently this is only supported on iOS 16.0 and later.

See also:

Implementation

Future<void> hide() async {
  assert(!_isDisposed);
  // This check prevents a given instance from accidentally hiding some other
  // instance, since only one can be visible at a time.
  if (this != _lastShown) {
    return;
  }
  _lastShown = null;
  // This may be called unnecessarily in the case where the user has already
  // hidden the menu (for example by tapping the screen).
  return _channel.invokeMethod<void>(
    'ContextMenu.hideSystemContextMenu',
  );
}