代码之家  ›  专栏  ›  技术社区  ›  Farhana Naaz Ansari Jay Dwivedi

禁用粘贴并从颤振的textformfield中选择所有功能按钮

  •  0
  • Farhana Naaz Ansari Jay Dwivedi  · 技术社区  · 6 年前

    我想禁用所有功能有关的复制,粘贴和选择所有的新闻 textformfield 在颤栗中。我有一个密码字段,可以接受键盘提示,并能够在默认情况下粘贴数据,但当我执行操作,如调用登录服务,然后密码字段出错。

     TextFormField(
          obscureText: true,
          style: styleText,
          textInputAction: TextInputAction.done,
          controller: _passwordController,
          focusNode: _passwordFocus,
          onFieldSubmitted: (term){
            _passwordFocus.unfocus();
          },
          keyboardType: TextInputType.text,
          validator: validatePassword,
          decoration: InputDecoration(
              focusedBorder: border,
              border: border,
              enabledBorder: border,
              hintStyle: styleText,
              hintText: 'Password'),
          onSaved: (String val) {
            _password = val;
          },
        ),
    
    0 回复  |  直到 6 年前
        1
  •  29
  •   anmol.majhail    6 年前

    你可以用 enableinteractiveSelection : false 禁用复制/粘贴。

    TextFormField(
              enableInteractiveSelection: false,
              obscureText: true,
              style: styleText,
              textInputAction: TextInputAction.done,
              controller: _passwordController,
              focusNode: _passwordFocus,
              onFieldSubmitted: (term){
                _passwordFocus.unfocus();
              },
              keyboardType: TextInputType.text,
              validator: validatePassword,
              decoration: InputDecoration(
                  focusedBorder: border,
                  border: border,
                  enabledBorder: border,
                  hintStyle: styleText,
                  hintText: 'Password'),
              onSaved: (String val) {
                _password = val;
              },
            ),