首页 > 解决方案 > 颤动:我想要中心的文字

问题描述

我有一排。在这一行中,我在图标中有两个小部件,一个是文本,在这一行中,我的图标固定在左侧,我希望我的文本在这一行的中心,我的图标将固定

在此处输入图像描述

这是我的代码。

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


标签: flutterflutter-layoutflutter-dependenciesflutter-animationflutter-test

解决方案


试试这个:

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

推荐阅读