繁体   English   中英

如何在 flutter 中的小部件上覆盖小部件

[英]How to overlay widget on widget in flutter

我需要在 Flutter 中的文本内容上构建一个带有红色圆圈的内容小部件,我该怎么办? 在此处输入图像描述

你可以使用stack小部件来做到这一点

return Scaffold(
      body: Center(
        child: Container(
          width: 450,
          height: 200,
          color: Colors.white,
          child: Stack(
            children: [
              Align(
                alignment: Alignment.center,
                child: Container(
                  width: 400,
                  height: 150,
                  decoration: BoxDecoration(
                    color: Colors.blue,
                    borderRadius:BorderRadius.circular(20)
                  ),
                ),
              ),
              Align(
                alignment: Alignment.topRight,
                child: Container(
                  width: 100,
                  height: 100,
                  decoration: BoxDecoration(
                    color: Colors.red,
                    shape: BoxShape.circle
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );

在此处输入图像描述

暂无
暂无

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

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