TextField Widget in Flutter Application is utilized to get information from clients and store that information into the information base. So in this article, we will be experiencing How to Disable TextField In Flutter?
How to Disable TextField In Flutter?
TextField presently has empowered property. where you can simply cripple the TextField like
new TextField(
enabled: false,
...
...
)
TextField and TextFormField both have a contention called empowered. You can handle it utilizing a boolean variable. enabled=true implies it will go about as an altering text field though enabled=false will Disable the TextField Widget.
Make AlwaysDisabledFocusNode and pass it to the focusNode property of a TextField Widget
class AlwaysDisabledFocusNode extends FocusNode {
@override
bool get hasFocus => false;
}
then
new TextField(
enableInteractiveSelection: false, // will disable paste operation
focusNode: new AlwaysDisabledFocusNode(),
...
...
)
Client can likewise attempt like an underneath:
TextField(
enableInteractiveSelection: false,
focusNode: FocusNode(),
)
enableInteractiveSelection will incapacitate content choice of TextField .
Like debilitated in HTML
TextField(
enable: false
)
You can likewise get it going like underneath:
AbsorbPointer(
absorbing: true, //To disable from touch use false while **true** for otherwise
child: Your WidgetsName
);
I have utilized a blend of readOnly and enableInteractiveSelection properties to accomplish the ideal conduct on the TextField Widget.
TextField(
readOnly: true,
enableInteractiveSelection: true,
onTap: () {
do_something(),
},
)
Conclusion:
In this article, We have experienced How to Disable TextField Widget In Flutter?
Continue Learning !!! Continue Fluttering !!!
In any case, need a Support for Flutter Development? Do tell us.
1 thought on “How to disable text edit field in flutter ?”