ThemeData() class 的哪个属性与更改应用栏的颜色有关?

Which one of the properties of the ThemeData() class is related to changing the color of the app bar?

我们可以像这样在应用程序的所有页面中编辑 scaffold 的默认颜色:

MaterialApp(
      theme: ThemeData(
        scaffoldBackgroundColor: Colors.red
      ),
    );

在这个例子中,我用 属性 scaffoldBackgroundColor: 改变了脚手架的颜色。我怎样才能对应用栏也执行此操作?

添加这个家伙:

return MaterialApp(
      theme: ThemeData(
        scaffoldBackgroundColor: Colors.red,
        appBarTheme: const AppBarTheme(
          backgroundColor: Colors.black,
          iconTheme: IconThemeData(color: Colors.white),
          titleSpacing: 0,
          centerTitle: false,
          titleTextStyle: TextStyle(
            color: Colors.white,
            fontSize: 16,
            fontFamily: "NunitoBL",
          ),
        ),
      ),
      home: Home(),
    );

您可以使用 AppBarTheme 类型

的 ThemeData 的 appBarTheme 属性

像这样使用它:

MaterialApp(
      theme: ThemeData(
        scaffoldBackgroundColor: Colors.red,
        appBarTheme: [const] AppBarTheme(
          backgroundColor: Colors.blue,
          // ...
        ),
      ),
    );