1

我试图在使用 TextFormField 时隐藏输入文本的下划线。我已经阅读了所有的建议,但没有一个能消除下划线!

child: TextFormField(
  autocorrect: false, 
  inputFormatters: [ new FilteringTextInputFormatter.allow(RegExp("[a-zA-Z0-9]"))],
  textAlign: TextAlign.center,
  decoration: InputDecoration(
     hintText: "i.e. noahsclearnews",
     hintStyle: TextStyle( color: Colors.grey, fontSize: ScreenUtil().setSp(40) ),
     border: InputBorder.none,
     focusedBorder: InputBorder.none,
     enabledBorder: InputBorder.none,
     errorBorder: InputBorder.none,
     disabledBorder: InputBorder.none,
  )
)

我错过了什么吗?

示例截图

4

2 回答 2

1

当您在键盘中独立于 FormField 输入未知单词时,这是一个原生下划线,实际上不是您的应用程序中的东西,而是 android 键盘中的东西。

但是您可以忽略那些将keyboardType 设置为TextInputType.visiblePassword 的更正。

TextFormField(
    autocorrect: false,
    keyboardType: TextInputType.visiblePassword, // Disabling word correction
    decoration: InputDecoration(
      hintText: "i.e. noahsclearnews",
    )
)
于 2020-10-14T20:20:46.063 回答
0

也许一个空格会起作用,写的时候给一个空格,你的下划线会被删除

于 2020-10-14T19:43:10.140 回答