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.
When it's pressed, it looks like this
How can I modify these highlights to be black instead of light blue? Thanks!
Try to change your inputDecoration labelStyle:
InputDecorationTheme(
labelStyle: TextStyle(
color: black,
fontSize: 12,
);
There are 2 ways you can modify the TextField's highlight color:
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,
),
),
),
)
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(),
);
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.