新增在TextFormField flutter中按下后缀图标时无法打开键盘

时间:2020-10-27 18:43:04

标签: flutter textformfield

预期:当我按下后缀图标时,如果键盘处于打开状态,请不要关闭它,否则不要打开它。

现实:当我按下后缀图标时,如果键盘处于打开状态,则仍会打开,但是当键盘处于关闭状态时,请快速将其打开。

我尝试了FocusScope.of(context).unfocus(),但没有成功

如果有帮助,请在此处粘贴代码。

 return TextFormField(
      //scrollPadding: EdgeInsets.all(30.0),

      controller: field_controller,
      validator: (text) {
        return field_validator(text);
      },
      keyboardType: keyboard_type,
      //maxLength: 30,
      textAlign: TextAlign.center,
      obscureText: _visible_password2,
      decoration: InputDecoration(
        hintText: field_name,
        labelText: field_name,
        suffixIcon:IconButton(
          autofocus: true,
          icon: Icon(
            !_visible_password2
                ? CupertinoIcons.eye
                : CupertinoIcons.eye_slash,
            size: 20.0,
            color:
            _visible_password2 ? Color(0xFF3f7182) : Color(0xFF707070),
          ),
          onPressed: () {
            //TODO : BUG

            setState(() {

              _visible_password2 = !_visible_password2;

            });
          },
        ),

0 个答案:

没有答案