Home > Enterprise >  Flutter TextFormField active color while not in focus
Flutter TextFormField active color while not in focus

Time:08-16

I would like the colour of a text field to remain active even if it is no longer in focus.

enter image description here

Here you can see the problem. If i unselect the TextFormField, the color of the icon and the underline changes.

enter image description here

I hope you can help me. Thank you!

CodePudding user response:

Include InputDecoration border color and icons color

TextFormField(
  keyboardType: TextInputType.number,
  decoration: const InputDecoration(
      prefix: Icon(
        Icons.abc,
        color: Colors.blue,
      ),
      suffixIcon: Icon(
        Icons.ac_unit,
        color: Colors.blue,
      ),
      suffixIconColor: Colors.blue,
      enabledBorder: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.blue),
      ),
      focusedBorder: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.blue),
      ),
      border: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.blue),
      )),
  style: TextStyle(
    color: Colors.purple,
  ),
),

More about InputDecoration

CodePudding user response:

 enabledBorder: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.red),
      ),
      focusedBorder: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.red),
      ),
      border: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.red),
      )),

Just add this in your decoration

  • Related