attach method

void attach()

Open a platform TextInput session. Idempotent.

Implementation

void attach() {
  if (isAttached) return;
  // Provide the viewId so the platform text input plugin can associate
  // the client with the correct FlutterView. Without this, TextInput.setClient
  // fails with "view ID is null" on Windows. (Same fix as AppFlowy #1126.)
  final viewId = PlatformDispatcher.instance.views.firstOrNull?.viewId;
  _conn = TextInput.attach(
    this,
    TextInputConfiguration(
      inputType: TextInputType.text,
      inputAction: TextInputAction.none,
      autocorrect: false,
      enableSuggestions: false,
      smartDashesType: SmartDashesType.disabled,
      smartQuotesType: SmartQuotesType.disabled,
      enableIMEPersonalizedLearning: false,
      viewId: viewId,
    ),
  );
  _resetEditing(notify: false);
  _conn!.show();
}