Search code examples
flutterdartcoding-stylecenteringappbar

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)),
              )
            ])),

Solution

  • 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)),
                  )
                ]))