Disable Word Underlining in TextFormField

送分小仙女□ 提交于 2020-12-26 01:59:22

问题


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.

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.

Here is how my TextFormField looks at the moment

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,
                        ),
                      ),
                    ),
                  ))),

回答1:


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

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

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

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.



来源:https://stackoverflow.com/questions/57498809/disable-word-underlining-in-textformfield

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!