I know there is a way to change text input color of TextField using the style: TextStyle()
property, but I want to change the text color from the ThemeData
widget.
Is there anyway to do that?
CodePudding user response:
Use:
style: TextStyle(color: Theme.of(context).primaryColor),
Replace primaryColor
with one of many colors defined in ThemeData
.
CodePudding user response:
ThemeData contains colorScheme, you can simply get the color from it.
To get primary color, it will be Theme.of(context).colorScheme.primary,
.
TextField(
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
),
TextField(
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
More about ColorScheme