Malak
Malak

Reputation: 441

Flutter Centering text in AppBar

i just want to Center this entire Text (of course it should be still in AppBar). Thx

i want to centre entire text

        appBar: AppBar(
            toolbarHeight: 80.0,
            backgroundColor: Colors.amber,
            title: Row(children: [
              Text("Text",
                  style: GoogleFonts.josefinSans(
                      textStyle: const TextStyle(fontSize: 40.0))),
              Text(
                "The Game",
                style: GoogleFonts.overpass(
                    textStyle: const TextStyle(fontSize: 20.0)),
              )
            ])),

Upvotes: 0

Views: 401

Answers (2)

Dinesh Nagarajan
Dinesh Nagarajan

Reputation: 1243

Include mainAxisAlignment to MainAxisAlignment.center in Row widget

Sample Code:

AppBar(
            toolbarHeight: 80.0,
            backgroundColor: Colors.amber,
            title: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
              Text("Text",
                  style: GoogleFonts.josefinSans(
                      textStyle: const TextStyle(fontSize: 40.0))),
              Text(
                "The Game",
                style: GoogleFonts.overpass(
                    textStyle: const TextStyle(fontSize: 20.0)),
              )
            ]))

Upvotes: 2

HoangAnhTran
HoangAnhTran

Reputation: 59

Use centerTitle : true

appBar: AppBar(
            centerTitle: true,
            toolbarHeight: 80.0,
            backgroundColor: Colors.amber,
            title: Row(children: [
              Text("Text",
                  style: GoogleFonts.josefinSans(
                      textStyle: const TextStyle(fontSize: 40.0))),
              Text(
                "The Game",
                style: GoogleFonts.overpass(
                    textStyle: const TextStyle(fontSize: 20.0)),
              )
            ])),

Upvotes: 1

Related Questions