【发布时间】:2021-08-30 23:10:29
【问题描述】:
当按钮状态处于禁用状态时,我想更改按钮文本颜色。通过使用 onSurface: MyColors.disable,我可以更改按钮背景禁用状态。但按钮文字没有改变。我该如何解决这个问题。这是我的代码,我试过了
class MyTheme {
MyTheme._();
static final ThemeData lightTheme = ThemeData(
scaffoldBackgroundColor: ShikhoColors.background,
primaryColor: ShikhoColors.background,
backgroundColor: ShikhoColors.background,
brightness: Brightness.light,
elevatedButtonTheme: ElevatedButtonThemeData(style: lightElevatedButtonStyle),
textButtonTheme: TextButtonThemeData(style: _lightTextButtonStyle),
outlinedButtonTheme: OutlinedButtonThemeData(style: _lightOutlinedButtonStyle),
cardTheme: _lightCardStyle,
);
static final ButtonStyle lightElevatedButtonStyle = ElevatedButton.styleFrom(
primary: ShikhoColors.blue_main,
// onSurface: ShikhoColors.disable,
padding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
elevation: 0.0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
textStyle: TextStyle(color: ShikhoColors.background, fontWeight: FontWeight.bold, fontSize: 16.0, fontFamily: 'HindSiliguri'),
);
...
}
【问题讨论】: