在TextFormField中禁用Word下划线 [英] Disable Word Underlining in TextFormField

查看:65
本文介绍了在TextFormField中禁用Word下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Flutter上进行应用程序设计,并努力解决这个看似简单的问题.在下面创建TextFormField时,无论我尝试了什么,输入文本始终带有下划线.我唯一想要的就是没有下划线的文字.

I am currently working on an app design in Flutter, and struggling with this seemingly easy problem. When creating the TextFormField below, the input text is always underlined, no matter of what I've tried. The only thing I want is text without this ugly underline.

此问题的可能原因是Android(我使用的是Android Emulator)会自动在输入形式的文本上加下划线,但这只是我想到的一种想法,我不确定这是否是我与TextFormField进行斗争的真正原因.无论如何,这是我的代码以及得到的信息.

Possibly the reason for this issue is that Android (I'm using an Android Emulator) automatically underlines text in input forms like this one, but this is just a thought that came to my mind and I am not sure if this is the real reason behind my struggle with the TextFormField. Anyway, here is my code and what I get.

这是我的TextFormField目前的外观

Container(
              margin: EdgeInsets.only(top: 10, left: 20, right: 30),
              child: Card(
                  elevation: 5.0,
                  child: Container(
                    child: TextFormField(
                      style: TextStyle(
                          fontSize: 18.0,
                          color: const Color(0xFF757575),
                          decoration: TextDecoration.none,
                          fontWeight: FontWeight.w500,
                          fontFamily: 'Montserrat'),
                      key: formKey,
                      onSaved: (text) => _input = text,
                      decoration: InputDecoration(
                        focusedBorder: InputBorder.none,
                        enabledBorder: InputBorder.none,
                        border: InputBorder.none,
                        prefixIcon: Icon(
                          Feather.getIconData("search"),
                          color: Colors.orange,
                        ),
                      ),
                    ),
                  ))),

推荐答案

此操作由您在Android上自动使用的键盘完成.

This is done by the keyboard you are using on Android automatically.

对于已禁用文本更正的用户,该信息将不会显示.

For users who have disabled text correction, this will not show up.

Android模拟器上,您可以在键盘设置中将其关闭: Settings -> System -> 语言&输入 -> 虚拟键盘 -> Gboard -> 文本更正.
您要查找的特定设置是 显示建议条自动更正 .如果您将其关闭,您将再也看不到下划线了.

On an Android emulator you can turn it off in the keyboard settings: Settings -> System -> Languages & Input -> Virtual Keyboard -> Gboard -> Text correction.
The specific settings you are looking for are Show suggestion strip and Auto-correction. If you turn these off, you will not be seeing the underlining anymore.

话虽如此,这与Flutter无关,您应该可能不应该关闭"此丑陋的下划线",因为用户希望具有此功能.
您可能可以改用 SelectableText 小部件并手动记录键盘输入来解决此问题,但是,这样做实际上没有意义,您会获得用户不熟悉的功能.

Having said that, this is not related to Flutter and you should probably not turn off "this ugly underline" as users expect to have this functionality.
You could probably work about it by using SelectableText widgets instead and manually recording the keyboard input, however, there is not really a point to do that and you would get functionality that does not feel familiar to your users.

这篇关于在TextFormField中禁用Word下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆