Huseyn
Huseyn

Reputation: 412

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

we can edit default color of scaffold in all pages in app like this :

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

In this example, I changed the color of the scaffold with Property scaffoldBackgroundColor:. How can I do this for the app bar as well?

Upvotes: 0

Views: 210

Answers (2)

M.mhr
M.mhr

Reputation: 1749

You can use appBarTheme property of ThemeData which is an AppBarTheme type

use it like this :

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

Upvotes: 1

Ary Anzh
Ary Anzh

Reputation: 474

add this dude:

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(),
    );

Upvotes: 1

Related Questions