showKeyboard method

void showKeyboard(
  1. BuildContext context
)

Opens the keyboard (requests focus from the platform text input).

Implementation

void showKeyboard(BuildContext context) {
  // Extract viewId from the current window using the context
  final int viewId = View.of(context).viewId;

  if (_connection == null || !_connection!.attached) {
    _attachConnection(viewId: viewId);
  }
  _connection?.show();
  // On web, position the hidden <textarea> using the real render box
  // transform and font style so IME popups appear next to the cursor.
  if (kIsWeb) {
    _updateWebImePosition();
    return;
  }
  // Send transform then caret rect immediately after show() so macOS
  // has everything it needs for firstRectForCharacterRange:.
  final h = _lastViewHeight;
  if (h != null) setViewHeight(h);
  final rect = _lastCaretRect;
  if (rect != null) {
    _connection?.setCaretRect(rect);
    _connection?.setComposingRect(rect);
  }
}