Disable a text edit field in flutter

后端 未结 11 1576
深忆病人
深忆病人 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条回答
  •  Happy的楠姐
    2020-12-23 17:17

    Use readOnly: true

    TextField(
      readOnly: true,
      controller: controller,
      obscureText: obscureText,
      onChanged: (value) {
        onValueChange();
      },
      style: TextStyle(
        color: ColorResource.COLOR_292828,
        fontFamily: Font.AvenirLTProMedium.value,
        fontSize: ScreenUtil().setHeight(Size.FOURTEEN)),
        decoration: InputDecoration(
        border: InputBorder.none,
        hintText: hint,
        hintStyle: TextStyle(
          fontSize: ScreenUtil().setHeight(Size.FOURTEEN),
          color: ColorResource.COLOR_HINT,
          fontFamily: Font.AvenirLTProBook.value)),
      ),
    

提交回复
热议问题