I need to disable TextFormField occasionally. I couldn't find a flag in the widget, or the controller to simply make it read only or disable. What is the best way to do it?
相关问题
- What means in Dart static type and why it differs
- Flutter : Prepare list data from http request
- How to schedule an alarm on specific time in Flutt
- MappedListIterable is not a SubType
- 'firebase_messaging/FirebaseMessagingPlugin.h&
相关文章
- Observatory server failed to start - Fails to crea
- Flutter error retrieving device properties for ro.
- Adding Shadows at the bottom of a container in flu
- Flutter. Check if a file exists before loading it
- Flutter - http.get fails on macos build target: Co
- Receive share file intents with Flutter
- Do stateless widgets dispose on their own?
- How to clean your build with Flutter RP2 in Androi
There is now a way to disable
TextField
andTextFormField
. See github here. Use it like this:I tried using FocuseNode(), enabled = false yet not working, Instead of that I use a widget called AbsorbPointer. It's use for preventing a widget from touch or tap, I wrap my TextFormField or other widget inside AbsordPointer Widgets and give a parameter to disable from touch
Example
There is another way this can be achieved which also does not cause this issue. Hope this might help someone.
Create
AlwaysDisabledFocusNode
and pass it to thefocusNode
property of aTextField
.then
Update:
TextField
now hasenabled
property. Where you can just disable theTextField
likeNote: This will also disable icon associated with text input.
Similar to readonly like in html
This can response to onTap.
Similar to disabled like in html
This can not response to onTap.
TextField
andTextFormField
both have an argument calledenabled
. You can control it using a boolean variable.enabled=true
means it will act as an editing text field whereasenabled=false
will disable theTextField
.