showSpellCheckSuggestionsToolbar method

bool showSpellCheckSuggestionsToolbar()

Shows toolbar with spell check suggestions of misspelled words that are available for click-and-replace.

Implementation

bool showSpellCheckSuggestionsToolbar() {
  // Spell check suggestions toolbars are intended to be shown on non-web
  // platforms. Additionally, the Cupertino style toolbar can't be drawn on
  // the web with the HTML renderer due to
  // https://github.com/flutter/flutter/issues/123560.
  if (!spellCheckEnabled ||
      _webContextMenuEnabled ||
      widget.readOnly ||
      _selectionOverlay == null ||
      !_spellCheckResultsReceived ||
      findSuggestionSpanAtCursorIndex(textEditingValue.selection.extentOffset) == null) {
    // Only attempt to show the spell check suggestions toolbar if there
    // is a toolbar specified and spell check suggestions available to show.
    return false;
  }

  assert(
    _spellCheckConfiguration.spellCheckSuggestionsToolbarBuilder != null,
    'spellCheckSuggestionsToolbarBuilder must be defined in '
    'SpellCheckConfiguration to show a toolbar with spell check '
    'suggestions',
  );

  _selectionOverlay!.showSpellCheckSuggestionsToolbar((BuildContext context) {
    return _spellCheckConfiguration.spellCheckSuggestionsToolbarBuilder!(context, this);
  });
  return true;
}