rozerro
rozerro

Reputation: 7216

elevatedButtonTheme's textStyle property does not change text color in ElevatedButton

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'),
      ),
    ),
),

Upvotes: 4

Views: 504

Answers (1)

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63799

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

Upvotes: 3

Related Questions