1

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 ?

wahyu
  • 1,679
  • 5
  • 35
  • 73

2 Answers2

2

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

Adel B-Lahlouh
  • 1,059
  • 1
  • 8
  • 20
  • 1
    thank you for the answer, I have try it, the line color become red but whenever I click the TextForm, the color will change into blue again – wahyu Apr 10 '21 at 08:16
  • You'll need to use the focusedBorder property in that case @uyhaW – Aulig Apr 05 '22 at 11:41
1

lets try

Theme(
        data: new ThemeData(
          primaryColor: Colors.redAccent,
          primaryColorDark: Colors.red,
        ),
        child: TextField(
          keyboardType: TextInputType.text,
          decoration: InputDecoration(
            
            labelText: "Text field*",
          ),
        ),
      ),
Jahidul Islam
  • 11,435
  • 3
  • 17
  • 38