showToolbar method

  1. @override
bool showToolbar()
override

Shows the selection toolbar at the location of the current cursor.

Returns false if a toolbar couldn't be shown, such as when the toolbar is already shown, or when no text selection currently exists.

Implementation

@override
bool showToolbar() {
  // Web is using native dom elements to enable clipboard functionality of the
  // context menu: copy, paste, select, cut. It might also provide additional
  // functionality depending on the browser (such as translate). Due to this,
  // we should not show a Flutter toolbar for the editable text elements
  // unless the browser's context menu is explicitly disabled.
  if (_webContextMenuEnabled) {
    return false;
  }

  if (_selectionOverlay == null) {
    return false;
  }
  _liveTextInputStatus?.update();
  clipboardStatus.update();
  _selectionOverlay!.showToolbar();
  // Listen to parent scroll events when the toolbar is visible so it can be
  // hidden during a scroll on supported platforms.
  if (_platformSupportsFadeOnScroll) {
    _listeningToScrollNotificationObserver = true;
    _scrollNotificationObserver?.removeListener(_handleContextMenuOnParentScroll);
    _scrollNotificationObserver = ScrollNotificationObserver.maybeOf(context);
    _scrollNotificationObserver?.addListener(_handleContextMenuOnParentScroll);
  }
  return true;
}