shouldCreateInputConnection property Null safety

bool shouldCreateInputConnection

Whether to create an input connection with the platform for text editing or not.

Read-only input fields do not need a connection with the platform since there's no need for text editing capabilities (e.g. virtual keyboard).

On the web, we always need a connection because we want some browser functionalities to continue to work on read-only input fields like:

  • Relevant context menu.
  • cmd/ctrl+c shortcut to copy.
  • cmd/ctrl+a to select all.
  • Changing the selection using a physical keyboard.


bool get shouldCreateInputConnection => kIsWeb || !widget.readOnly;