Disable a `TextField` in Flutter

Use the enabled: property of the TextField widget by setting it to false:

TextField(
  enabled: false,
  ...
)

This field won't respond to onTap events - it is similar to a disabled field in HTML.

Use focusNode and enableInteractiveSelection to make a TextField in Flutter readonly so that it can respond to the onTap events:

TextField(
  focusNode: FocusNode(),
  enableInteractiveSelection: false,
  ...
)

Subscribe to My Newsletter

The latest programming-related news, articles and resources - sent to your inbox monthly. Unsubscribe anytime.