简体   繁体   中英

Flutter TextFormField active color while not in focus

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

在此处输入图像描述

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

在此处输入图像描述

I hope you can help me. Thank you!

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

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM