Change TextField's Underline in Flutter

后端 未结 4 540
长情又很酷
长情又很酷 2020-12-09 02:54

I\'m working on an application using Flutter SDK. When I use a TextField widget, and I focus it, the underline becomes blue. I need to change this color to red, how can I do

4条回答
  •  佛祖请我去吃肉
    2020-12-09 03:35

    You can also change its color by following ways.

    1. Wrap your TextField in Theme and provide accentColor

      Theme(
        data: Theme.of(context).copyWith(accentColor: Colors.red),
        child: TextField(),
      )
      
    2. Using inputDecoration property.

      TextField(
        decoration: InputDecoration(
          focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(color: Colors.red),
          ),
        ),
      )
      

提交回复
热议问题