How to Center Title in Appbar in Flutter?

Learn to Center Title in Appbar widget of your Flutter app, creating a polished and visually appealing user interface for your mobile applications.

Here we are going to use 6 different ways to convert integer values to double data types with examples and explanations.

In this guide, we are going to use 4 different ways to center the title in AppBar in Flutter and also copy the full source code to the center of the body and title text.

Follow the official documentation to set up Flutter: Flutter Installation Guide.

Center Title in Appbar Flutter

4 Ways to Center Title in Appbar in Flutter

In Flutter, you can center the title in the AppBar using various methods. Here’s how you can achieve it using different approaches:

1. Using the centerTitle Property

Flutter provides a centerTitle property within the AppBar widget that allows you to center the title text.

   AppBar(
     centerTitle: true,
     title: Text('Centered Title'),
   )

2. Customizing Title Alignment

You can use the title property of the AppBar to place any widget you want, such as a Center widget, to achieve the same effect.

   AppBar(
     title: Center(
       child: Text('Centered Title'),
     ),
   )

3. Using the FlexibleSpace Property

You can wrap the title within the FlexibleSpace widget and set its alignment to centerTitle.

   AppBar(
     flexibleSpace: Center(
       child: Text('Centered Title'),
     ),
     centerTitle: true,
   )

4. Customizing AppBar Height

You can customize the height of the AppBar and then center the title using a Center widget within the PreferredSize widget.

   AppBar(
     title: PreferredSize(
       preferredSize: Size.fromHeight(60.0), // Adjust the height as needed
       child: Center(
         child: Text('Centered Title'),
       ),
     ),
   )

Each of these methods accomplishes the same goal of centering the title within the AppBar in Flutter. Choose the one that best fits your design preferences and requirements.

Check Out:

Full Code to Center Title in AppBar in Flutter

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          // Centering the title
          centerTitle: true,
          // Title of the AppBar
          title: Text('AppOverride Center'),
        ),
        body: Center(
          child: Text('AppOverride Centered Title Example'),
        ),
      ),
    );
  }
}

Output

Center Title in AppBar in Flutter Output

Bottom Line

These Flutter methods all achieve the same outcome: placing the title in the center of the AppBar. The best choice depends on your design style and project needs.

Share:
Ambika Dulal

Ambika Dulal is a Flutter Developer from Nepal who is passionate about building beautiful and user-friendly apps. She is always looking for new challenges and is eager to learn new things. She is also a strong believer in giving back to the community and is always willing to help others.

Leave a Comment

AO Logo

App Override is a leading mobile app development company based in Kathmandu, Nepal. Specializing in both Android and iOS app development, the company has established a strong reputation for delivering high-quality and innovative mobile solutions to clients across a range of industries.

Services

UI/UX Design

Custom App Development

Mobile Strategy Consulting

App Testing and Quality Assurance

App Maintenance and Support

App Marketing and Promotion

Contact

App Override

New Plaza, Kathmandu