Khamidjon Khamidov
Khamidjon Khamidov

Reputation: 8859

How do I disable any widget in Flutter?

In my app, I need to disable many widgets many times. But I cannot find convenient way to do so? I would appreciate your help.

Upvotes: 11

Views: 18628

Answers (3)

Nanang Fitrianto
Nanang Fitrianto

Reputation: 678

if you use inkwell, so pass null to onTap.

Upvotes: -3

Ashok
Ashok

Reputation: 3581

You can wrap any widget in flutter with the AbsorbPointer widget so that you can enable or disable the widget:

body: AbsorbPointer(
  absorbing: true,
  child: ...
)

The value true on absorbing will disable any tap on the child.

Upvotes: 37

Abhishek singh
Abhishek singh

Reputation: 92

if you are talking about TextField widget you can set readOnly atribute to true. If its a checkBox or DropdownButton pass null for onChanged attribute.

Upvotes: 1

Related Questions