如何使用textTheme在ElevatedButton?



我正在从RaisedButton迁移到ElevatedButton,但有一些东西我不知道如何做到这一点,在我的themeData我有:

buttonTheme: ButtonThemeData(
buttonColor: PRIMARY_COLOR,
textTheme: ButtonTextTheme.primary,
)

textTheme是我喜欢的东西,因为它使用黑色或白色的颜色取决于背景颜色,这是一个拯救生命。如何在ElevatedButton上做到这一点?没有textTheme

昨天看到这个,我想这应该适合你。

elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
textStyle: MaterialStateProperty.resolveWith(
(states) => TextStyle(
// add your styles here
),
),
),
),

这就是它现在的工作方式

最新更新