I have tried to define the Input decoration to change the color of underline of input TextField. But it's not working. can anyone suggest what am i missing here ?
Here is the Code snippet :
decoration: InputDecoration(
hintText: 'Username',
hintStyle: TextStyle(color: Colors.white),
border: new UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white,
width: 1.0, style: BorderStyle.none ),
),
In Flutter, you can customize the color, thickness, and style (actually, there are only 2 stypes for underline: solid and none) of a TextFIeld's underline by using the parameters from the InputDecoration class listed below: enabledBorder. focusedBorder.
To remove TextField underline/border in Flutter, you can simply set the border property to InputBorder. none. This will remove the underline for all states such as Focused, Enabled, Error, Disabled.
Step 1: Locate the file where you have placed the Text widget. Step 2: Inside the Text widget, add the Style parameter and assign the TextStyle widget. Step 3: Inside the TextStyle widget, add the color parameter and set the color of your choice. For example, color: Colors.
By default, a TextField is decorated with an underline. You can add a label, icon, inline hint text, and error text by supplying an InputDecoration as the decoration property of the TextField . To remove the decoration entirely (including the underline and the space reserved for the label), set the decoration to null.
In Flutter, you can customize the color, thickness, and style (actually, there are only 2 types for underline: solid and none) of a TextFIeld’s underline by using the parameters from the InputDecoration class listed below: The example below will give you a more intuitive look.
In this blog post, let’s check how to change the default color of TextField border in Flutter. You can change the border color of your TextField using InputDecoration class, OutlineInputBorder class, and BorderSide class. See the code snippet given below.
We would also change TextField underline color on focus. 1. Import material.dart package in your app’s main.dart file. 2. Call our main MyApp class using void main runApp () method. 3. Create Scaffold widget -> SafeArea widget -> Center widget in Widget build area in MyApp class. 4. Create TextField widget in Center widget wrap in Container widget.
It comes up with a default light blue color bottom underline. If you have any doubts when changing the color, you can speak with an agency and get an idea. Textfield is an important element that allows users to input relevant details like name, password, address, and a lot more.
We have to use both enabledBorder
and focusedBorder
.
enabledBorder
: It will work when TextField
not having focus. focusedBorder
: It will work when TextField
has the focus.enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black
),
),
// and:
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With