Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
io.flutter.embedding.engine.systemchannels.SpellCheckChannel Class Reference

Classes

interface  SpellCheckMethodHandler
 

Public Member Functions

 SpellCheckChannel (@NonNull DartExecutor dartExecutor)
 
void setSpellCheckMethodHandler ( @Nullable SpellCheckMethodHandler spellCheckMethodHandler)
 

Public Attributes

final MethodChannel channel
 
final MethodChannel.MethodCallHandler parsingMethodHandler
 

Detailed Description

SpellCheckChannel is a platform channel that is used by the framework to initiate spell check in the embedding and for the embedding to send back the results.

When there is new text to be spell checked, the framework will send to the embedding the message SpellCheck.initiateSpellCheck with the String locale to spell check with and the String of text to spell check as arguments. In response, the io.flutter.plugin.editing.SpellCheckPlugin will make a call to Android's spell check service to fetch spell check results for the specified text.

Once the spell check results are received by the io.flutter.plugin.editing.SpellCheckPlugin, it will send back to the framework the
ArrayList<HashMap<String,Object>>
of spell check results (see io.flutter.plugin.editing.SpellCheckPlugin#onGetSentenceSuggestions for details). The io.flutter.plugin.editing.SpellCheckPlugin only handles one request to fetch spell check results at a time; see io.flutter.plugin.editing.SpellCheckPlugin#initiateSpellCheck for details.

io.flutter.plugin.editing.SpellCheckPlugin implements SpellCheckMethodHandler to initiate spell check. Implement SpellCheckMethodHandler to respond to spell check requests.

Definition at line 37 of file SpellCheckChannel.java.

Constructor & Destructor Documentation

◆ SpellCheckChannel()

io.flutter.embedding.engine.systemchannels.SpellCheckChannel.SpellCheckChannel ( @NonNull DartExecutor  dartExecutor)
inline

Definition at line 75 of file SpellCheckChannel.java.

75 {
76 channel = new MethodChannel(dartExecutor, "flutter/spellcheck", StandardMethodCodec.INSTANCE);
77 channel.setMethodCallHandler(parsingMethodHandler);
78 }

Member Function Documentation

◆ setSpellCheckMethodHandler()

void io.flutter.embedding.engine.systemchannels.SpellCheckChannel.setSpellCheckMethodHandler ( @Nullable SpellCheckMethodHandler  spellCheckMethodHandler)
inline

Sets the SpellCheckMethodHandler which receives all requests to spell check the specified text sent through this channel.

Definition at line 84 of file SpellCheckChannel.java.

85 {
86 this.spellCheckMethodHandler = spellCheckMethodHandler;
87 }

Member Data Documentation

◆ channel

final MethodChannel io.flutter.embedding.engine.systemchannels.SpellCheckChannel.channel

Definition at line 40 of file SpellCheckChannel.java.

◆ parsingMethodHandler

final MethodChannel.MethodCallHandler io.flutter.embedding.engine.systemchannels.SpellCheckChannel.parsingMethodHandler
Initial value:
=
new MethodChannel.MethodCallHandler() {
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
if (spellCheckMethodHandler == null) {
Log.v(
TAG,
"No SpellCheckeMethodHandler registered, call not forwarded to spell check API.");
return;
}
String method = call.method;
Object args = call.arguments;
Log.v(TAG, "Received '" + method + "' message.");
switch (method) {
case "SpellCheck.initiateSpellCheck":
try {
final ArrayList<String> argumentList = (ArrayList<String>) args;
String locale = argumentList.get(0);
String text = argumentList.get(1);
spellCheckMethodHandler.initiateSpellCheck(locale, text, result);
} catch (IllegalStateException exception) {
result.error("error", exception.getMessage(), null);
}
break;
default:
result.notImplemented();
break;
}
}
}
static void v(@NonNull String tag, @NonNull String message)
Definition Log.java:40
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static ::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)
GAsyncResult * result
void initiateSpellCheck( @NonNull String locale, @NonNull String text, @NonNull MethodChannel.Result result)
std::u16string text

Definition at line 44 of file SpellCheckChannel.java.

45 {
46 @Override
47 public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
48 if (spellCheckMethodHandler == null) {
49 Log.v(
50 TAG,
51 "No SpellCheckeMethodHandler registered, call not forwarded to spell check API.");
52 return;
53 }
54 String method = call.method;
55 Object args = call.arguments;
56 Log.v(TAG, "Received '" + method + "' message.");
57 switch (method) {
58 case "SpellCheck.initiateSpellCheck":
59 try {
60 final ArrayList<String> argumentList = (ArrayList<String>) args;
61 String locale = argumentList.get(0);
62 String text = argumentList.get(1);
63 spellCheckMethodHandler.initiateSpellCheck(locale, text, result);
64 } catch (IllegalStateException exception) {
65 result.error("error", exception.getMessage(), null);
66 }
67 break;
68 default:
69 result.notImplemented();
70 break;
71 }
72 }
73 };
void Log(const char *format,...) SK_PRINTF_LIKE(1
call(args)
Definition dom.py:159

The documentation for this class was generated from the following file: