0

I am trying to change my labelText color when focused. I can change the text color but not when focused. In the screenshots below, the string "Email" remains blue when focused.

This is what I have:

Container(
  margin: EdgeInsets.symmetric(horizontal: 600),
  child: TextField(
    decoration: InputDecoration(
      border: UnderlineInputBorder(),
      labelText: 'Email',
      suffix: Icon(
        Icons.check,
      ),
    ),
  ),
),
                  

This is what the button looks like before it's pressed.

enter image description here

When it's pressed, it looks like this

enter image description here

How can I modify these highlights to be black instead of light blue? Thanks!

  • check [this](https://stackoverflow.com/a/56411859/9661936) and [this](https://stackoverflow.com/a/56846793/9661936) – Dung Ngo Feb 01 '21 at 02:01

2 Answers2

0

Try to change your inputDecoration labelStyle:

InputDecorationTheme(
      labelStyle: TextStyle(
    color: black,
    fontSize: 12,
  );
Jim
  • 6,928
  • 1
  • 7
  • 18
0

There are 2 ways you can modify the TextField's highlight color:

  1. Use InputDecoration (do this if you want to locally modify a single TextField)
Container(
  child: TextField(
    decoration: InputDecoration(
      focusedBorder: UnderlineInputBorder(
        borderSide: BorderSide(color: Colors.black),
      ),
      labelText: 'Email',
      labelStyle: TextStyle(color: Colors.black),
      suffix: Icon(
        Icons.check,
      ),
    ),
  ),
)
  1. Config the theme property of the MaterialApp widget (do this if you want to set a common theme across all TextField widgets):
MaterialApp(
      theme: ThemeData(
          inputDecorationTheme: InputDecorationTheme(
        focusedBorder:
            UnderlineInputBorder(borderSide: BorderSide(color: Colors.black)),
        labelStyle: TextStyle(color: Colors.black),
      ),
   ),
   home: SomeScreen(),
);
Bach
  • 2,928
  • 1
  • 6
  • 16