【问题标题】:Underlined When Writing - Flutter - Textfield写作时加下划线 - Flutter - Textfield
【发布时间】:2020-06-05 10:19:04
【问题描述】:

每当我写这个词时,都会有下划线。我一写一个新词,下划线就不再是下划线,而是我现在写的。我可以以某种方式发出在写作时没有下划线的问题吗?我也没有在论坛里找到任何东西。

child: TextField(
                  autocorrect: false,
                  style: TextStyle(
                    fontSize: 22.0,
                  ),
                  cursorColor: Colors.black,
                  decoration: InputDecoration(
                    hintText: 'Search',
                    border: InputBorder.none,
                    icon: Icon(
                      Icons.search,
                      color: Color(0xFFe1F5FE),
                    ),
                  ),
                ),

【问题讨论】:

  • 您描述的行为似乎是由于您在设备上的设置,进行拼写检查。我可以看到您也启用了键盘顶部的自动提示栏。
  • 好的,当然。我不必通过应用程序发出它。
  • 尝试Textfieldautocorrect属性并将其设置为false@Florian

标签: flutter flutter-layout


【解决方案1】:

你试过focusedBorder吗?

TextField(
      decoration: new InputDecoration(
          border: InputBorder.none,
          focusedBorder: InputBorder.none,
          contentPadding: EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
          hintText: 'what you want'
      ),
    ),

【讨论】:

  • 根据我从文档中了解到的情况,focusedBorder 在焦点集中并且没有任何错误时将边框应用于整个字段。 O.P. 将该行为描述为当前输入的单词下划线,但在写入新单词后将停止下划线。
【解决方案2】:

将此代码放入 TextField 中

keyboardType: TextInputType.text,

例子:

TextField(
                 keyboardType: TextInputType.text,
                  autocorrect: false,
                  style: TextStyle(
                    fontSize: 22.0,
                  ),
                  cursorColor: Colors.black,
                  decoration: InputDecoration(
                    hintText: 'Search',
                    border: InputBorder.none,
                    icon: Icon(
                      Icons.search,
                      color: Color(0xFFe1F5FE),
                    ),
                  ),
                ),

【讨论】:

    猜你喜欢
    • 2018-07-20
    • 2018-08-08
    • 2020-10-15
    • 2021-11-15
    • 1970-01-01
    • 2018-09-11
    • 2019-02-13
    • 2022-11-30
    • 2020-09-11
    相关资源
    最近更新 更多