我想禁用所有与复制,粘贴和选择有关的所有功能,只需在颤振中按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 :(得分:2)
您可以使用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;
},
),
答案 1 :(得分:0)
您可以尝试disable any particular option
并非所有选项。
TextFormField(
toolbarOptions: ToolbarOptions(
copy: true,
cut: true,
paste: false,
selectAll: false,
),
...
..
.