定位的小部件可以工作,但是对齐的小部件在堆栈中的小部件中不起作用

时间:2019-05-01 00:15:35

标签: flutter flutter-positioned

为什么当我尝试使用align对齐时,他的孩子不动, 但定位后就可以使用(我想使用它,因为我无法在所有移动尺寸中居中)

这是我的代码:

 @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: _launchURL,
      child: Container(
        child: Container(
          child: Stack(children: <Widget>[
            Column(
              children: <Widget>[
                Container(
                  decoration: new BoxDecoration(
                    border: Border.all(color: Colors.black12),
                    borderRadius: BorderRadius.all(Radius.circular(13)),
                    shape: BoxShape.rectangle,
                    color: Colors.white,
                    boxShadow: <BoxShadow>[
                      BoxShadow(
                        color: Colors.black26,
                        offset: Offset(3, 7),
                        blurRadius: 7.0,
                      ),
                    ],
                  ),
                  height: 140,
                  width: MediaQuery.of(context).size.width * 0.42,
                ),
              ],
            ),
         // this the code when I use the align widget
         // Align(
         //   alignment: Alignment.bottomCenter,
            Positioned(
              top: MediaQuery.of(context).size.width * 0.42 / 7,
              left: 40,
              child: Container(
                child: Column(
                  children: <Widget>[
                    Container(
                      decoration: new BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(16)),
                        shape: BoxShape.rectangle,
                        color: Colors.transparent,
                        boxShadow: <BoxShadow>[
                          BoxShadow(
                            color: Colors.grey,
                            offset: Offset(2, 5),
                            blurRadius: 5.0,
                          ),
                        ],
                      ),
                      child: ClipRRect(
                        borderRadius: new BorderRadius.circular(16.0),
                        child: Image.asset(
                          "assets/RoundStyle/" + socialBadge + ".png",
                          height: 60,
                          width: 60,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 20,
                    ),
                    MyText3(
                      "@hisname",
                      color: Colors.grey,
                    )
                  ],
                ),
              ),
            ),
          ]),
        ),
      ),
    );
  }

就是这样,谢谢:)

1 个答案:

答案 0 :(得分:1)

如果要将小部件放在cluster_id num_observations 0 6 1 4 2 1 3 3 4 29 5 5 中,则不需要StackColumn。只需将其添加为Container

child
相关问题