Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/flutter_onscreen_keyboard/lib/src/onscreen_keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,22 @@ class _OnscreenKeyboardState extends State<OnscreenKeyboard>
setState(() => _mode = modes[(i + 1) % modes.length]);
}

@override
void setModeNamed(String modeName) {
if (_mode == modeName) return;

if (_layout.modes.containsKey(modeName)) {
setState(() {
_mode = modeName;
});
} else {
debugPrint(
"OnScreenKeyboard: Keyboard mode '$modeName' "
'not found on the KeyboardLayout.',
);
}
}

final GlobalKey _keyboardKey = GlobalKey();

/// Alignment of the keyboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ abstract interface class OnscreenKeyboardController {
/// Calling this method switches the current mode to the next one,
/// wrapping around to the first mode when the end is reached.
void switchMode();

/// Sets the keyboard mode to the one specified by [modeName].
///
/// The [modeName] must exist in the current [KeyboardLayout.modes].
void setModeNamed(String modeName);
}