如果我向我的应用程序添加一个主题,如下所示:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Color(0xff393e46),
primaryColorDark: Color(0xff222831),
accentColor: Color(0xff00adb5),
backgroundColor: Color(0xffeeeeee),
buttonTheme: ButtonThemeData(
buttonColor: Color(0xff00adb5),
)
),
home: Scaffold(
body: MyHomePage(),
),
);
}
}
如何更改按钮主题的文本颜色?
如果你使用ButtonTextTheme.primary
Flutter 会自动为您选择正确的颜色。
例如,如果您将buttonColor
像这样黑
ThemeData(
. . .
buttonTheme: ButtonThemeData(
buttonColor: Colors.deepPurple, // <-- dark color
textTheme: ButtonTextTheme.primary, // <-- this auto selects the right color
)
),
文本自动变浅。如果你做了buttonColor
亮,则文字变暗。
ThemeData(
. . .
buttonTheme: ButtonThemeData(
buttonColor: Colors.yellow, // <-- light color
textTheme: ButtonTextTheme.primary, // <-- dark text for light background
)
),
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)