![](/img/trans.png)
[英]Clickable icon on TextFormField - disable TextFormField focus on icon click (Flutter)
[英]Disable paste and select all function button from textformfield in flutter
我想在 flutter 中按下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;
},
),
您可以使用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;
},
),
您可以尝试disable any particular option
而不是所有选项。
TextFormField(
toolbarOptions: ToolbarOptions(
copy: true,
cut: true,
paste: false,
selectAll: false,
),
...
..
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.