首页 > 解决方案 > 我如何将卡片水平和垂直居中,即在活动的中心

问题描述

嗨,我想将一张应该水平和垂直居中的卡片居中,我试图通过定位小部件来实现这一点,但无法这样做。

这就是我得到的: 在此处输入图像描述

这是我的代码:

Positioned(
                 
                child:
              Card(
                shape: RoundedRectangleBorder(
                  borderRadius:BorderRadius.circular(30.0),
                  side: BorderSide(color: Color.fromRGBO(214, 0, 27, 1)),
                ),
                  child: Column(
                  children: <Widget>[
                        Container(
                        margin: EdgeInsets.only(top: 10),
                        child: Row(
                          children: <Widget>[
                            Container(
                              child: Text("hello@xyz.com",
                                  style: TextStyle(
                                      fontWeight: FontWeight.normal,
                                      color: Colors.black,
                                      fontSize: 16)),
                            )
                          ],
                        ))
               ],
                ),
              ),
              ),

标签: flutterdart

解决方案


在您的小部件之前,请使用中心小部件。

 Card(
    child: Center(
    child: YourWidgets()
    ))

推荐阅读