繁体   English   中英

Flutter 如何设置堆栈小部件的样式

[英]Flutter how to style stack widget

我如何在颤振中设置我的 Stack 小部件的样式以获得这样的布局

在此处输入图片说明

  1. 您可以使用Stack小部件将两个视图放在一起。
  2. boxShadow应用于较小的容器,以赋予其在视图中呈现的那种效果。

我添加了一个演示:

Stack(
      children: [
        Container(
          height: 80,
          width: 80,
          decoration: new BoxDecoration(
            shape: BoxShape.circle,
            color: Colors.purple,
          ),
          child: Center(
            child: Text(
              'b',
              style: TextStyle(
                fontSize: 50,
                color: Colors.white,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
        ),
        Positioned(
          bottom: 0, // change the values to preferred values
          right: 5, // change the values to preferred values
          child: Container(
            height: 25,
            width: 25,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              color: Colors.white,
              boxShadow: [
                BoxShadow(
                  offset: Offset(0.0, 1),
                  spreadRadius: 2,
                  blurRadius: 2,
                  color: Colors.black.withOpacity(
                    0.2,
                  ),
                ),
              ],
            ),
            child: Center(
              child: Icon(
                Icons.camera,
                size: 15,
              ),
            ),
          ),
        ),
      ],
    );

结果:

结果

暂无
暂无

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

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