【问题标题】:Unable to hide text underline in TextFormField无法在 TextFormField 中隐藏文本下划线
【发布时间】:2020-10-14 19:38:07
【问题描述】:

我试图在使用 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,
  )
)

我错过了什么吗?

【问题讨论】:

    标签: flutter textformfield


    【解决方案1】:

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

    但您可以忽略那些将键盘类型设置为 TextInputType.visiblePassword 的更正。

    TextFormField(
        autocorrect: false,
        keyboardType: TextInputType.visiblePassword, // Disabling word correction
        decoration: InputDecoration(
          hintText: "i.e. noahsclearnews",
        )
    )
    

    【讨论】:

    • 设置键盘:TextInputType.visiblePassword 没有删除文本上的下划线。或者您是说将其设置为可见密码只是消除了其更正文本的愿望?
    • 设置键盘:TextInputType.visiblePassword 没有删除文本上的下划线。在我完全重启应用程序之前,由于某种原因,热重载是不够的。谢谢!
    【解决方案2】:

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

    【讨论】:

    • 用户名中不允许有空格。
    猜你喜欢
    • 2020-01-20
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 2021-11-15
    • 1970-01-01
    • 2023-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多