by @kodeazy

flutter how to change color of appBar in scaffold widget of dart file?

Home » flutter » flutter how to change color of appBar in scaffold widget of dart file?
  • In this blog we will be discussing about how to change the color of AppBar in Scaffold -Below is the syntax to change the color

     AppBar(
        title: Text("Change Color"),
        backgroundColor: Colors.red,// changes the color of AppBar to red
      )
  • Blow is an Example code on how to change color of AppBar to red in Scaffold widget.

    import 'package:flutter/material.dart';
    void main() {
    runApp(const MyApp());
    }
    class MyApp extends StatelessWidget {
    const MyApp({Key? key}) : super(key: key);
    @override
    Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Demo Application',
      home: Scaffold(
          appBar: AppBar(
        title: Text("Change Color"),
        backgroundColor: Colors.red,// changes the color of AppBar to red
      )),
    );
    }
    }