Custom AppBar Flutter

// ./components/appBar.dart
import 'package:flutter/material.dart';

class CustomAppBar extends StatelessWidget with PreferredSizeWidget {
  final String _title;

  @override
  final Size preferredSize;

  CustomAppBar(this._title, { Key key}) : preferredSize = Size.fromHeight(50.0),
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return AppBar( // your customization here
      title: Text('$_title'),
      centerTitle: true,
      backgroundColor: Colors.black54,
    );
  }
}

// on the file using the appBar just: 

import 'package:flutter/material.dart';
import 'package:photo_app/components/appBar.dart';

class Albums extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar('Your title here'),
    );
  }
}

4
2
KEM_6 75 points

                                    Scaffold(
  appBar: PreferredSize(
    preferredSize: Size.fromHeight(120), // Set this height
    child: Container(
      color: Colors.orange,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text('One'),
          Text('Two'),
          Text('Three'),
          Text('Four'),
        ],
      ),
    ),
  ),
)

4 (2 Votes)
0
4.17
6
Rod Russell 125 points

                                    class Sample1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        drawer: Drawer(),
        appBar: MyCustomAppBar(
          height: 150,
        ),
        body: Center(
          child: FlutterLogo(
            size: MediaQuery.of(context).size.width / 2,
          ),
        ),
      ),
    );
  }
}

class MyCustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final double height;

  const MyCustomAppBar({
    Key key,
    @required this.height,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          color: Colors.grey[300],
          child: Padding(
            padding: EdgeInsets.all(30),
            child: AppBar(
                    title: Container(
                      color: Colors.white,
                      child: TextField(
                        decoration: InputDecoration(
                          hintText: "Search",
                          contentPadding: EdgeInsets.all(10),
                        ),
                      ),
                    ),
                    actions: [
                      IconButton(
                        icon: Icon(Icons.verified_user),
                        onPressed: () => null,
                      ),
                    ],
                  ) ,
          ),
        ),
      ],
    );
  }
  
 @override
  Size get preferredSize => Size.fromHeight(height);
}

4.17 (6 Votes)
0
0
0
Rod Russell 125 points

                                    class Sample1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        drawer: Drawer(),
        appBar: MyCustomAppBar(
          height: 150,
        ),
        body: Center(
          child: FlutterLogo(
            size: MediaQuery.of(context).size.width / 2,
          ),
        ),
      ),
    );
  }
}

class MyCustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final double height;

  const MyCustomAppBar({
    Key key,
    @required this.height,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          color: Colors.grey[300],
          child: Padding(
            padding: EdgeInsets.all(30),
            child: AppBar(
                    title: Container(
                      color: Colors.white,
                      child: TextField(
                        decoration: InputDecoration(
                          hintText: "Search",
                          contentPadding: EdgeInsets.all(10),
                        ),
                      ),
                    ),
                    actions: [
                      IconButton(
                        icon: Icon(Icons.verified_user),
                        onPressed: () => null,
                      ),
                    ],
                  ) ,
          ),
        ),
      ],
    );
  }
  
 @override
  Size get preferredSize => Size.fromHeight(height);
}

0
0
0
0
Rod Russell 125 points

                                    class Sample1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        drawer: Drawer(),
        appBar: MyCustomAppBar(
          height: 150,
        ),
        body: Center(
          child: FlutterLogo(
            size: MediaQuery.of(context).size.width / 2,
          ),
        ),
      ),
    );
  }
}

class MyCustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final double height;

  const MyCustomAppBar({
    Key key,
    @required this.height,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          color: Colors.grey[300],
          child: Padding(
            padding: EdgeInsets.all(30),
            child: AppBar(
                    title: Container(
                      color: Colors.white,
                      child: TextField(
                        decoration: InputDecoration(
                          hintText: "Search",
                          contentPadding: EdgeInsets.all(10),
                        ),
                      ),
                    ),
                    actions: [
                      IconButton(
                        icon: Icon(Icons.verified_user),
                        onPressed: () => null,
                      ),
                    ],
                  ) ,
          ),
        ),
      ],
    );
  }
  
 @override
  Size get preferredSize => Size.fromHeight(height);
}

0
0
0
0
Rod Russell 125 points

                                    class Sample1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        drawer: Drawer(),
        appBar: MyCustomAppBar(
          height: 150,
        ),
        body: Center(
          child: FlutterLogo(
            size: MediaQuery.of(context).size.width / 2,
          ),
        ),
      ),
    );
  }
}

class MyCustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final double height;

  const MyCustomAppBar({
    Key key,
    @required this.height,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          color: Colors.grey[300],
          child: Padding(
            padding: EdgeInsets.all(30),
            child: AppBar(
                    title: Container(
                      color: Colors.white,
                      child: TextField(
                        decoration: InputDecoration(
                          hintText: "Search",
                          contentPadding: EdgeInsets.all(10),
                        ),
                      ),
                    ),
                    actions: [
                      IconButton(
                        icon: Icon(Icons.verified_user),
                        onPressed: () => null,
                      ),
                    ],
                  ) ,
          ),
        ),
      ],
    );
  }
  
 @override
  Size get preferredSize => Size.fromHeight(height);
}

0
0
0
0
Rod Russell 125 points

                                    class Sample1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        drawer: Drawer(),
        appBar: MyCustomAppBar(
          height: 150,
        ),
        body: Center(
          child: FlutterLogo(
            size: MediaQuery.of(context).size.width / 2,
          ),
        ),
      ),
    );
  }
}

class MyCustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final double height;

  const MyCustomAppBar({
    Key key,
    @required this.height,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          color: Colors.grey[300],
          child: Padding(
            padding: EdgeInsets.all(30),
            child: AppBar(
                    title: Container(
                      color: Colors.white,
                      child: TextField(
                        decoration: InputDecoration(
                          hintText: "Search",
                          contentPadding: EdgeInsets.all(10),
                        ),
                      ),
                    ),
                    actions: [
                      IconButton(
                        icon: Icon(Icons.verified_user),
                        onPressed: () => null,
                      ),
                    ],
                  ) ,
          ),
        ),
      ],
    );
  }
  
 @override
  Size get preferredSize => Size.fromHeight(height);
}

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
flutter appbar customized appbar flutter design flutter appbar styling how to use a custom appbar flutter how to style flutter app bar style appbar flutter create a appbar flutter add custom appbar in Flutter customize appbar flutter Custominze app bar in flutter make custom app bar flutter how to make a custom appbar flutter Flutter custom appbar class dart custom appbar flutter appbar with custom flutter appbar custom widget flutter flutter 2 custom appbar custom appbar code in flutter custom, app bar flutter flutter appbar style flutter style AppBar custom app bar style flutter appbar design flutter how to make an appbar in flutter custome appbar widget how to customise the appbar flutte appbar custom flutter app bar customize flutter Flutter creating a custom AppBar custom appbar in flutter pub app bar "actions" in custom appbar flutter app bar actions in custom appbar flutter how to design appbar in flutter how to design a appbar in flutter design of Appbar in flutter how to design custom app bar in flutter create custom appbar widgets in flutter how to make an appbar flutter Flutter how to customise the AppBar how to custom app bar flutter flutter designing custom appbar flutter appbar through custom widget app bar customizations flutter custom container in appbar flutter custom appbar flutter make appbar in flutter cool appbar flutter flutter create appbar widget how to make a good appbar in flutter create custom Appbar fluuter custom appbar widget flutter flutter setup appbar how to create custom appbar in flutter flutter material appbar custom how to make custom appbar in deferent dart file in flutter customized appbar flutter flutter customize appbar how to create appbar in flutter create appbar in flutter Flutter customize app bar appbar flutter custom 5 ways to customise appbar flutter how to make custom appbar flutter how to make custom app bar flutter flutter appbar customization make a custom app bar in flutter how to create a custom app bar in flutter flutter appbar container appbar flutter flutter appBar appbar flutterr appbar modification image and text Custom appbar in flutter how to custom the icon in flutter appbar appbar properties flutter appbar in flutter how to custom the bottomappbar in flutter flutter add custom appbar custom tool bar flutter flutter appbar design flutter make generic app bar appbar custom icon flutter scaffold custom appbar use a container in appbar flutter customize appbar in flutter flutter body with container like appbar how to make custom appbar in flutter flutter preferred size custom appbar flutter custom appbar widget flutter custom app bar widget flutter custom appbar flutter sliver appbar custom use custom appbar flutter build appbar in flutter flutter custom app bar flutter custom toolbar how to do an custon appbar flutter how to customize app bar in flutter how give custom icon in app bar in flutter create custom app bar flutter flutter appbar custom how make cool app bar flutter custom appbar flutte make content in appbar flutter custumize AppBar in flutter can we assign appBar property custom made widget create custom appbar flutter custom silver app bar flutter customse appbar Title use container as appbar flutter how to customize appbar in flutter creating custom app bar in flutter custome widget app bar custom app bar flutter custom appbar flutter custom appbar Appbar flutter create costum create costum appbar Appbar flutter create custom flutter how make widget appbar how to customize an appbar customized app bar in flutter custom app bar examples flutter how to add widgets in an appbar in flutter completly custmo appbar using glutter flutter custom title flutter custom appbar flutter create custom appbar
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source