问题
Here is the code. I want to remove the black underline just below text, and currently the TextField is in edit mode:
TextField(
autofocus: true,
decoration: InputDecoration.collapsed(
hintText: "Search",
border: InputBorder.none,
),
maxLines: 1,
)
回答1:
Try to give a TextStyle to your TextField widget. Your TextField is getting your default Theme's TextStyle.
TextField(
autofocus: true,
style: TextStyle(color: Colors.white, fontSize: 30),
decoration: InputDecoration.collapsed(
hintText: "Search",
border: InputBorder.none,
),
maxLines: 1,
)
In TextField widgets source code it states:
/// If null, defaults to the `subhead` text style from the current [Theme].
final TextStyle style;
回答2:
You have to add a "decoration:TextDecoration.none", like this:
Text(
"Don't forget",
style: TextStyle(
decoration: TextDecoration.none
)
)
回答3:
You should use TextDecoration.none
in decoration
property.
Text(
'your txt',
style: TextStyle( decoration: TextDecoration.none),
)
回答4:
@Immortal Dude is right that this is not the problem of textfield. Because when you click somewhere else after typing in the textfield, the underline automatically remove from the text.
You just need to set the keyboard type:
keyboardType: TextInputType.visiblePassword,
来源:https://stackoverflow.com/questions/56315495/how-to-remove-underline-below-textfield