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

Time:01-30

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?

CodePudding user response:

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

CodePudding user response:

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,
          // ...
        ),
      ),
    );
  •  Tags:  
  • Related