Home > Software design >  Flutter Center Title Not True
Flutter Center Title Not True

Time:10-04

In Flutter, the title is still off center. Appreciate any suggestions. Below is updated code with icon.

appBar: AppBar(
        backgroundColor: hdrcolor,
        automaticallyImplyLeading: false,
        leading: IconButton(
          onPressed: () {
            Get.to(() => LandingPageWidget())
                .whenComplete(() => initState());
          },
          icon: Icon(
            Icons.arrow_back,
            color: dayBlue,
          ),
        ),
        title: Center(
            child: Text(
          widget.apiName,
          style: Theme.bodyText1.override(
              fontFamily: 'Lexend Exa', color: txtcolor, fontSize: 26),
        )),
        actions: [],
        centerTitle: true,
        elevation: 4,
      ),

CodePudding user response:

I don't think you need to wrap the title with the Center widget. The implementation is pretty simple. Considering that this is part of an AppBar widget.

Scaffold(
  appBar: AppBar(
    centerTitle: true,
    title: Text(
      'A Centered Title',
  ),
), 
  • Related