Package io.flutter.plugin.editing

# Class SpellCheckPlugin

java.lang.Object
io.flutter.plugin.editing.SpellCheckPlugin

All Implemented Interfaces:
  `SpellCheckerSession.SpellCheckerSessionListener`, `SpellCheckChannel.SpellCheckMethodHandler`

public class SpellCheckPlugin extends Object implements SpellCheckChannel.SpellCheckMethodHandler, SpellCheckerSession.SpellCheckerSessionListener
`SpellCheckPlugin` is the implementation of all functionality needed for spell check for text input.

The plugin handles requests for spell check sent by the `SpellCheckChannel` via sending requests to the Android spell checker. It also receives the spell check results from the service and sends them back to the framework through the `SpellCheckChannel`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `END_INDEX_KEY`
  `static final String`
  `START_INDEX_KEY`
  `static final String`
  `SUGGESTIONS_KEY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SpellCheckPlugin(TextServicesManager textServicesManager, SpellCheckChannel spellCheckChannel)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `destroy()`
  Unregisters this `SpellCheckPlugin` as the `SpellCheckChannel.SpellCheckMethodHandler`, for the `SpellCheckChannel`, and closes the most recently opened `SpellCheckerSession`.
  `void`
  `initiateSpellCheck(String locale, String text, MethodChannel.Result result)`
  Initiates call to native spell checker to spell check specified text if there is no result awaiting a response.
  `void`
  `onGetSentenceSuggestions(SentenceSuggestionsInfo[] results)`
  Callback for Android spell check API that decomposes results and send results through the `SpellCheckChannel`.
  `void`
  `onGetSuggestions(SuggestionsInfo[] results)`
  `void`
  `performSpellCheck(String locale, String text)`
  Calls on the Android spell check API to spell check specified text.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### START_INDEX_KEY

    public static final String START_INDEX_KEY
    See Also:
      - Constant Field Values

  - ### END_INDEX_KEY

    public static final String END_INDEX_KEY
    See Also:
      - Constant Field Values

  - ### SUGGESTIONS_KEY

    public static final String SUGGESTIONS_KEY
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### SpellCheckPlugin

    public SpellCheckPlugin(@NonNull TextServicesManager textServicesManager, @NonNull SpellCheckChannel spellCheckChannel)

- ## Method Details

  - ### destroy

    public void destroy()
    Unregisters this `SpellCheckPlugin` as the `SpellCheckChannel.SpellCheckMethodHandler`, for the `SpellCheckChannel`, and closes the most recently opened `SpellCheckerSession`.

    Do not invoke any methods on a `SpellCheckPlugin` after invoking this method.

  - ### initiateSpellCheck

    public void initiateSpellCheck(@NonNull String locale, @NonNull String text, @NonNull MethodChannel.Result result)
    Initiates call to native spell checker to spell check specified text if there is no result awaiting a response.
    Specified by:
      `initiateSpellCheck` in interface `SpellCheckChannel.SpellCheckMethodHandler`

  - ### performSpellCheck

    public void performSpellCheck(@NonNull String locale, @NonNull String text)
    Calls on the Android spell check API to spell check specified text.

  - ### onGetSentenceSuggestions

    public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results)
    Callback for Android spell check API that decomposes results and send results through the `SpellCheckChannel`.

    Spell check results are encoded as dictionaries with a format that looks like

         {
           startIndex: 0,
           endIndex: 5,
           suggestions: [hello, ...]
         }

    where there may be up to 5 suggestions.
    Specified by:
      `onGetSentenceSuggestions` in interface `SpellCheckerSession.SpellCheckerSessionListener`

  - ### onGetSuggestions

    public void onGetSuggestions(SuggestionsInfo[] results)
    Specified by:
      `onGetSuggestions` in interface `SpellCheckerSession.SpellCheckerSessionListener`