flutter: I want text in Center

Issue

I have a row. In this row I have two widget one in Icon and One is Text,In this row my icon fixed in left side and I want my text in center of this row and my Icon will fixed

enter image description here

This is my code.

          child: Column(
            children: [
              Container(
                color: mPrimaryColor,
                height: MediaQuery.of(context).size.height / 23,
                width: MediaQuery.of(context).size.width,
                child: Row(

                  children: [
                    SizedBox(
                      width: 15,
                    ),
                    InkWell(
                      onTap: () {
                        Navigator.pop(context);
                      },
                      child: Container(
                        height: MediaQuery.of(context).size.height / 23,
                    width: 30,
                        child: Icon(
                          Icons.arrow_back_ios_rounded,
                          size: 20,
                          color: whitetext,
                        ),
                      ),
                    ),
Spacer(),
                    Text(
                      // "${widget.headerName}".tr(),
                      "ADMINISTRATIVE CONTACT",
                      style: headingWhite(),
                      textAlign: TextAlign.center,
                    ),
                    Spacer(),
                  ],
                ),
              ),],),


Solution

try this:

          children: [
            SizedBox(
              width: 15,
            ),
            InkWell(
              onTap: () {
                Navigator.pop(context);
              },
              child: Container(
                height: MediaQuery.of(context).size.height / 23,
            width: 30,
                child: Icon(
                  Icons.arrow_back_ios_rounded,
                  size: 20,
                  color: whitetext,
                ),
              ),
            ),
            Expanded(child: Center(child: Text(
              // "${widget.headerName}".tr(),
              "ADMINISTRATIVE CONTACT",
              style: headingWhite(),
              textAlign: TextAlign.center,
            ),),),
            SizedBox(
              width: 45,
            ),
          ],

Answered By – Jim

Answer Checked By – Robin (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *