如何解决Flutter:如何防止光标句柄消失?
尝试将光标定位在 TextField
内时,光标手柄会自动消失,并停止拖动。这是显示效果的 gif:
有没有办法阻止这种行为并保持手柄可见(即拖动活动),直到释放鼠标或手指从屏幕上移开?
@override
Widget build(BuildContext context) {
_focusNode.requestFocus();
return TextField(
focusNode: _focusNode,maxLength: 64,expands: false,maxLines: 1,controller: _textEditController,onChanged: _onTextChanged,autocorrect: false,decoration: new Inputdecoration(
border: new OutlineInputBorder(),hintText: "Goal",labelText: "Goal",),);
}
解决方法
您可以使用以下代码。我希望能解决您的问题。
TextFormField(
autovalidateMode: AutovalidateMode.always,maxLength: 64,expands: false,maxLines: 1,controller: _textEditController,autocorrect: false,decoration: new InputDecoration(
border: new OutlineInputBorder(),hintText: "Goal",labelText: "Goal",),onSaved: (String value) {
// This optional block of code can be used to run
// code when the user saves the form.
},validator: (String value) {
return value.contains('@') ? 'Do not use the @ char.' : null;
},)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。