Disable a text edit field in flutter

后端 未结 11 1573
深忆病人
深忆病人 2020-12-23 17:05

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?

11条回答
  •  -上瘾入骨i
    2020-12-23 17:21

    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

    AbsorbPointer(
          absorbing: true,  //To disable from touch use false while **true** for otherwise
          child: Your WidgetsName
    );
    

提交回复
热议问题