Flutter 如何删除TextFormField中输入文本的下划线?
我想删除您在文本下看到的黑色下划线。每当我输入任何字符和每个字符的插件时,它就会出现。我怎样才能做到这一点? 这是我的TextFieldForm代码:Flutter 如何删除TextFormField中输入文本的下划线?,flutter,Flutter,我想删除您在文本下看到的黑色下划线。每当我输入任何字符和每个字符的插件时,它就会出现。我怎样才能做到这一点? 这是我的TextFieldForm代码: TextFormField( controller: _controller, showCursor: false, toolbarOptions: ToolbarOptions( cut: true, copy: false,
TextFormField(
controller: _controller,
showCursor: false,
toolbarOptions: ToolbarOptions(
cut: true,
copy: false,
selectAll: true,
paste: true,
),
decoration: InputDecoration(
border: InputBorder.none,
filled: true,
fillColor: Colors.white,
hintStyle: TextStyle(fontSize: 20),
hintText: "Search the word",
contentPadding: EdgeInsets.only(left: 20),
enabledBorder: OutlineInputBorder(borderSide: BorderSide.none),
suffixIcon:
Icon(Icons.search, color: Colors.black.withOpacity(0.6)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide.none,
),
),
),
我尝试了“border:InputBorder.none”,但失败了……使用此函数:
focusedBorder: InputBorder.none,
我想你必须在装饰下面加上
focusBorder
,就像这样:
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
),
我想这是针对你设备的操作系统。这是一个自动完成选项。如您所见,按空格键时,它会删除下划线(表示单词已结束)。您已在手机设置中禁用它,与您的代码无关。为此,请尝试以下操作:
您可以重写TextField小部件中的inputFormatters,并将自定义格式化程序类放入数组中,如下面的代码段所示 我的自定义格式化程序类:
class CaseFormatting extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
return TextEditingValue(
text: newValue.text,
selection: newValue.selection
);
}
}
在文本字段中,将类添加到inputFormatters中
TextField(
//...
inputFormatters: [
CaseFormatting(),
// FilteringTextInputFormatter.allow(RegExp(r"[A-Z0-9]+")),
],
//...
)
这回答了你的问题吗?不,我仍然得到这个下划线我想这是因为键盘而不是文本字段不知道@SanjaySharmasorry,因为我没有看到他们的问题不是删除文本字段下的边框线,而是正在输入的文本的自动下划线样式。