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,
)
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;
You should use TextDecoration.none in decoration property.
Text(
'your txt',
style: TextStyle( decoration: TextDecoration.none),
)
I suspect it's something to do with the predictive text. The underlines disappear when you press the space bar to end the word you're typing; they then start appearing again when you start typing the next word. As suggested here, try setting TextInputType.visiblePassword; - this worked for me.
just code ...
TextFormField(
decoration: InputDecoration(
hintText: 'comment..',
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
contentPadding: EdgeInsetsDirectional.only(start: 10.0),
),
)
style:TextStyle(
decorationThickness: 0)
As stated in https://stackoverflow.com/a/57499189/445887
This is an accessibility feature (if you still see an underline after disabling it in TextStyle) from the Android keyboard.
Then input text is always underlined while typing use:
autocorrect: false,
enableSuggestions: false,
https://stackoverflow.com/a/69921656/10932271
Provide the following code inside the TextField widget and change the color according to the background color of a TextField. If the background is white provide white color which will make the underline invisible.
style: TextStyle(
fontSize: 16,
letterSpacing: 1,
decoration: TextDecoration.none,
decorationStyle: TextDecorationStyle.dotted,
decorationColor: Colors.white),
You have to add a "decoration:TextDecoration.none", like this:
Text(
"Don't forget",
style: TextStyle(
decoration: TextDecoration.none
)
)
#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,
Related
I set the cursorHeight property of flutter's TextField, but when there is no content in the TextField, the cursor cannot be vertically centered with the hintText, as shown in the following figure:
However, when there is content in the TextField, the content text and the cursor will be vertically centered, as shown in the following figure:
This is my code:
TextField(
decoration: const InputDecoration(
hintText: "Type here to add a quick TODO...",
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
contentPadding: EdgeInsets.all(0),
),
cursorHeight: 25,
cursorRadius: Radius.circular(10),
maxLines: 1,
style: TextStyle(
fontSize: 15,
),
onChanged: (value) {
setState(() {
_typedContent = value;
});
},
Is there any way to make the cursor center vertically even when there is no text input?
Custom the height of the text (height property)
TextField(
style: TextStyle(
height: 1.5
),
),
Firstly you can remove the cursorHeight property if it is not a must.
Second option is using the height property of your TextStyle. As far as I remember you can start trying with following ratio: cursorHeight/textSize. In any case I recommend you reading about height property of TextStyle.
style: TextStyle(
fontSize: 15,
height: 25/15
),
How to add red asterisk in label of TextFormField In Flutter
Using this code you can achieve that kind of styling in flutter.
TextField(
decoration: InputDecoration(
hintText: 'Ciao',
suffixText: '*',
suffixStyle: TextStyle(
color: Colors.red,
),
),
),
I'm using a textfield widget:
TextField(
controller: _taskNamecontroller,
focusNode: _focus,
textInputAction: TextInputAction.done,
maxLines: null,
decoration: InputDecoration(
border: InputBorder.none,
hintText: SC.current.taskHeaderTaskName),
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
height: 1.25),
),
and when adding this emoji 1️⃣ from the keyboard, it renders very strangely, it shows the 1 followed by a weird symbol:
Why is Flutter failing to render this emoji appropriately?
use GoogleFonts.notoColorEmojiCompat() for style
I have a big problem with DateTimeFormField on Flutter. I can't change hint, label, or default text style color change.
I already try this;
var textStyle = TextStyle(
color: Hexcolor("#D8D8D8"),
fontSize: ScreenUtil().setSp(42.0),
);
return DateTimeFormField(
mode: widget.mode,
label: widget.label,
decoration: InputDecoration(
filled: true,
fillColor: Hexcolor("#F9F9F9"),
contentPadding: EdgeInsets.only(
left: 20.0,
top: 20.0,
bottom: 5.0,
),
prefixStyle: textStyle,
hintStyle: textStyle,
labelStyle: textStyle,
border: defaultBorder,
focusedBorder: focusedBorder,
enabledBorder: enabledBorder,
),
onDateSelected: widget.onDateSelected,
//controller: widget.controller,
//maxLines: maxLines,
//obscureText: obscureText,
);
But color looks like this image :
How can I change the field default color?
Never used the Hexcolor plugin, why don't you try with a basic Color like:
Colors.lightBlue
And then maybe other method with Hexa:
Color(0xFF8BC34A)
I have a TextField like this, where the input text and the hint text are sized differently.
TextField(
style: Theme.of(context).textTheme.subhead.copyWith(
fontSize: 70.0,
),
decoration: InputDecoration(
hintText: 'Enter a number',
hideDivider: true,
hintStyle: TextStyle(
color: Colors.grey[500],
fontSize: 25.0,
),
),
);
While the user input text is centered in my parent container, the hintText is not (top has more space than the bottom). Is there a way to vertically center the hint text as well?
The reason the hint text is not the same size as the input text is that it takes up more space than the green Container has, so it looks like Enter a nu..., which isn't very user friendly. (So alternatively, is there a way to have a newline in the hintText?)
I see this is over 2 years old but in case others run into this problem:
InputDecoration has the property contentPadding.
TextField(
decoration: InputDecoration(
hintText: 'Hint Text',
contentPadding: EdgeInsets.all(10.0),
),
);
Add textAlignVertical: TextAlignVertical.center, in your TextField.
Note: make sure you are not modifying it with other Containers or anything else & if you do then check those widgets as well.
TextField(
textAlignVertical: TextAlignVertical.center,
),
new TextField(
decoration: new InputDecoration(
hintText: 'your hint',
),
textAlign: TextAlign.center,
)
textAlign: TextAlign.center will make your hint appear in the center.
Below is the solution for your problem:
Container(
color: Colors.red,
width: 1000,
height: 500,
alignment: Alignment.center,
child: TextFormField(
keyboardType: TextInputType.emailAddress,
autofocus: false,
style: new TextStyle(fontSize: 20),
decoration: InputDecoration(
hintText: 'Email', hintStyle: TextStyle(color: Color(0xff777777))),
),
)