【发布时间】:2021-09-27 02:59:32
【问题描述】:
【问题讨论】:
-
@JohnJoe,很遗憾,但没有。我将应用栏的颜色设置为白色,一切正常,但另一个应用栏的颜色(当您在手机上打开应用程序堆栈时出现)保持不变。它仍然具有材料设计的默认蓝色。
【问题讨论】:
如果您想为整个应用程序更改此颜色,您需要更改 ThemeData 如下:
MaterialApp(
theme: ThemeData(
// changing theme color
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.blue,
).copyWith(
secondary: Colors.green,
),
// for changing text color and style
textTheme: TextTheme(
bodyText1: TextStyle(),
bodyText2: TextStyle(),
).apply(
bodyColor: Colors.orange,
displayColor: Colors.blue,
),
),
)
但如果您只需要更改单个页面上的 appBar 颜色,请使用:
appBar: AppBar(
backgroundColor: Colors.red //or whatever you want
【讨论】:
只需在 AppBar 中添加 backgroundColor 即可:
AppBar(
backgroundColor: add color,
),
【讨论】: