I have a TextFormField, which contains a prefix Icon that I would like to turn red when it is focused on.
To achieve that, I have wrapped the TextFormField with a Theme object (Relevant SO Question):
Theme(data:ThemeData(colorScheme:
ThemeData().colorScheme.copyWith(primary:Colors.red)),
child: TextFormField()
This works great, but the problem arises when I switch to Dark mode inside my application. Because I am using this setting (I am assuming), it turns the entire TextFormField to use the primary color which is black and then the entire TextFormField is black.
Other TextFormField elements which I have not wrapped with a Theme object, are styled correctly according to theme.
How would I go about fixing this?
What I would like to achieve is have the TextFormField appear like the others in Dark mode and be highlighted red when it is focused on, regardless of light or dark mode.
Would I need to define a custom application theme for this?