isImeConnectionOpen static method
Returns true
if the given SuperEditor widget currently has an open IME connection,
or false
if no IME connection is open, or if SuperEditor is in keyboard mode.
By default, this method expects a single SuperEditor in the widget tree and
finds it byType
. To specify one SuperEditor among many, pass a superEditorFinder
.
Implementation
static bool isImeConnectionOpen([Finder? finder]) {
final element = (finder ?? find.byType(SuperEditor)).evaluate().single as StatefulElement;
final superEditor = element.widget as SuperEditor;
// Keyboard mode never has an IME connection.
if (superEditor.inputSource == TextInputSource.keyboard) {
return false;
}
final imeInteractorElement = find
.descendant(
of: find.byWidget(superEditor),
matching: find.byType(SuperEditorImeInteractor),
)
.evaluate()
.single as StatefulElement;
final imeInteractor = imeInteractorElement.state as SuperEditorImeInteractorState;
return imeInteractor.isAttachedToIme;
}