How to change appbar color in Flutter
To change the color of the AppBar in Flutter, you can modify the backgroundColor property of the AppBar widget. Here’s an example of how to change the AppBar color:
import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( backgroundColor: Colors.blue, // Change this to any color you desire title: Text('AppBar Color Example'), ), body: Center( child: Text( 'Hello, Flutter!', style: TextStyle(fontSize: 24), ), ), ), ); } }
Above example, the ‘backgroundColor’ property of the AppBar is set to ‘Colors.blue’, but you can replace it with any color you want. You can use named colors from the Colors class or specify colors using hexadecimal values.
Read Also: Flutter change color of text – Flutter Tips
If you want to use a custom color, you can use the Color class constructor with RGBA values:
Color customColor = Color.fromRGBO(255, 0, 127, 1.0); // Reddish pink color
Just update the ‘backgroundColor’ property of the AppBar widget to reflect your desired color.