I define a textStyle
for the elevatedButtonTheme
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Color(0xff64ffda)),
textStyle: MaterialStateProperty.all(TextStyle(color: Colors.black)),
),
),
But it does not change ElevatedButton
text color, what is wrong with it?
Should it work the way I describeb?
child: ElevatedButton(
onPressed: _submit,
child: Padding(
child: Text(
AppLocalizations.key(context, 'save'),
),
),
),
CodePudding user response:
From the documentation, we can see there about textStyle
The color of the [textStyle] is typically not used directly, the [
foregroundColor
] is used instead.
And for foregroundColor
This color is typically used instead of the color of the [
textStyle
]. All of the components that compute defaults from [ButtonStyle
] values compute a default [foregroundColor
] and use that instead of the [textStyle
]'s color.
There for to change text color on button use foregroundColor
More about ButtonStyle