If you use ButtonTextTheme.primary
Flutter will automatically select the right color for you.
For example, if you make the buttonColor
dark like this
ThemeData(
. . .
buttonTheme: ButtonThemeData(
buttonColor: Colors.deepPurple, // <-- dark color
textTheme: ButtonTextTheme.primary, // <-- this auto selects the right color
)
),
The text is automatically light. And if you make the buttonColor
light, then the text is dark.
ThemeData(
. . .
buttonTheme: ButtonThemeData(
buttonColor: Colors.yellow, // <-- light color
textTheme: ButtonTextTheme.primary, // <-- dark text for light background
)
),