简体   繁体   English

如何在 flutter 中重叠这两个小部件

[英]How to overlap these two widgets in flutter

Expected output of circle avatar and Container期望圆形头像和Container为output

Current situation, the circle avatar is not on top目前情况,圆圈头像不在最上面

    return Scaffold(
      body: Column(
        children: [
          Row(
            children: [
              Padding(
                padding: EdgeInsets.only(top:screenLayout(45, context),left: screenLayout(55, context)),
                child: Text('My Profile',
                 style: TextStyle(
                   fontWeight: FontWeight.bold,
                   color: color_mode.tertiaryColor,
                   letterSpacing: 1.3,
                   fontSize: screenLayout(43, context),
                   //add font later
                   //--//
                 ),
         ),
              ),
            ],
          ),
          verticalSpace(40, context),
          Stack(
            children: [
              Positioned(
                child: Container(
                  height: getHeight(context)/3,
                  width: getWidth(context)/1.13,
                  decoration: const BoxDecoration(
                    color: Colors.grey
                  ),
                ),
              ),
               Positioned(
                left: getWidth(context)/3.7,
                  top: getHeight(context)/4,
                  child: CircleAvatar(
                    maxRadius: screenLayout(130, context),
                  ),
               ),
            ],
          ),
        ],
      ),
      );

Try to use stack in a bigger scope, maybe outside the column.尝试在更大的 scope 中使用堆栈,也许在列之外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM