How To Change Flutter Appbar Height

flutter appbar height

In this post, we both will be discussing how to change Flutter appbar height with step by step explanation and a proper Flutter example. I am sure all your doubts will be cleared regarding Flutter appbar height customization after you finish reading this post. So let’s not wait anymore and jump right into understanding how to change Flutter appbar height.

What is Flutter Appbar Height?

Flutter appbar height as the name suggests, it is the vertical size of the Flutter appbar. We will see what the default Flutter appbar height is and how to change it depending on the requirements of your Flutter app. So let’s get right into implementing it using a proper Flutter example.

Default Flutter Appbar Height

In order to visualize the default Flutter appbar height, you just have to implement a simple Flutter appbar widget. See the below code:

appBar: AppBar()
flutter appbar default height
This is the default Flutter appbar height which you can see in the above image. In the next section, we will see how to customize the height of the Flutter appbar.

Change Flutter Appbar Height

Now to change the height of Flutter appbar widget, you have to use the toolbar height constructor of the Flutter appbar widget class. This constructor takes a double(decimal) value but you can pass integer as well, it will convert that integer to double automatically. For demonstration, I have passed a value of 100 to see what changes it will make to the Flutter appbar height. See the below code:

 appBar: AppBar(
      toolbarHeight: 100,
    )
flutter appbar change height
As you can see that the height of the Flutter appbar is increased, you can increase or decrease the Flutter appbar height by giving the toolbar height constructor greater or less value.
In this way, you can change the Flutter appbar height. If you have any queries regrading the customization of Flutter appbar height then do let me know in the comment section. I would love to answer all your questions.
In the next section, a complete source code of the customized Flutter appbar height along with some other decoration is given.

Customized Flutter Appbar Height Source Code

flutter appbar height

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(
      debugShowCheckedModeBanner: false,
      home: Homepage(),
    );
  }
}
class Homepage extends StatefulWidget {
  @override
  State<Homepage> createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
            appBar: AppBar(
      toolbarHeight: 100,
      centerTitle: true,
      title: Text(
        'Customized Flutter Appbar Height',
        style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700),
      ),
    )));
  }
}

Conclusion

In summary, you have now learned practically with proper code implementation of what Flutter appbar height is and how to customize it in your Flutter appbar widget. I appreciate your time for reading this post and would appreciate your feedback regarding this post. I have many other posts for you on Flutter widgets, Flutter application development, Flutter animation programs, Flutter templates with source code and many more. Thank you for reading this post.

Leave a Comment

Your email address will not be published.