Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a change the underline color of textField in flutter?

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 ),
    ),
like image 630
venu gopal Gupta Avatar asked Jul 17 '18 05:07

venu gopal Gupta


People also ask

How do you underline TextField in Flutter?

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.

How do you get rid of the blue underline in TextField in Flutter?

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.

How do you change the text color on Flutter?

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.

How do you customize a TextField in Flutter?

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.

How to underline a text in flutter?

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.

How to change the default color of textfield border in flutter?

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.

How to change textfield underline color on focus in Android?

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.

What is the color of the bottom underline of the textfield?

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.


1 Answers

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
  ),
),
like image 65
Jitesh Mohite Avatar answered Sep 25 '22 01:09

Jitesh Mohite