wahyu
wahyu

Reputation: 2405

How to change color style of TextField in flutter

I have a simple TextField widget like this

TextField(
      obscureText: widget.placeholder == "Password" ? _isHidePassword : false,
      decoration: InputDecoration(
        
        hintText: "${widget.placeholder}",
        hintStyle: TextStyle(
          color: Colors.grey,
        ),
        // labelText: "${widget.placeholder}",
        // labelStyle: TextStyle(color: greenMain),
      ),
    )

and it gives the result like this picture: enter image description here

is there a way to change the blue color into another? like red or green one ?

Upvotes: 1

Views: 5487

Answers (2)

Osama Abu-Tareih
Osama Abu-Tareih

Reputation: 21

You can use the decoration on TextField like this:

decoration: InputDecoration(
hintText: 'Type Text Here',        
enabledBorder: UnderlineInputBorder(      
borderSide: BorderSide(color: Colors.red),   
), 

And this will change the line to color red.

I hope i help you

Upvotes: 2

Jahidul Islam
Jahidul Islam

Reputation: 12575

lets try

Theme(
        data: new ThemeData(
          primaryColor: Colors.redAccent,
          primaryColorDark: Colors.red,
        ),
        child: TextField(
          keyboardType: TextInputType.text,
          decoration: InputDecoration(
            
            labelText: "Text field*",
          ),
        ),
      ),

Upvotes: 1

Related Questions