I would like to change the colour of the prefix icon in a textfield using themes.
I've tried this: -
iconTheme: IconThemeData(
color: Colors.red
),
But the above only changes the icons that are not in a textfield. I've also tried setting the primary colour like this:-
primaryColor: Colors.red,
But that only changes the focused colour of the icon. How do I change the unfocused colour of the prefix icon using themes?
Add this to your App's ThemeData class:
iconTheme: IconThemeData(
color: Colors.white
)
And then write this in your TextField widget
prefixIcon: Icon(Icons.ac_unit,color: AppTheme.darkTheme.iconTheme.color)
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.