簡體   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