【问题标题】:How do I get one element of Stack to appear outside another element?如何让 Stack 的一个元素出现在另一个元素之外?
【发布时间】:2021-04-02 09:37:00
【问题描述】:

Here's the issue visually explained 我正在尝试使用 Stack 小部件将文本小部件堆叠在放置在中心的圆形头像上。 当我尝试使用 Positioned 小部件将其放置在圆形头像的底部和右侧时,文本小部件似乎被剪裁了。

Stack(
          children: <Widget>[
                // circle avatar has to be on the center
                CircleAvatar(
                  radius: 40, //making the border of circleAvatar appear amber colored
                  backgroundColor: Colors.amber[900],
                  child: CircleAvatar(
                    // backgroundImage:
                    //     AssetImage('assets/images/img1.png'),
                    radius: 38,
                  ),
                ),

                // this has to be on the right near the  circle avatar on the same row
                Positioned(
                  bottom: 0,
                  right: 0,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Text('Dummytext1'),
                      SizedBox(
                        height: 5,
                        width: 5,
                      ),
                      Text('dummytext2')
                    ],
                  ),
                ),
              ]),

【问题讨论】:

    标签: flutter user-interface dart


    【解决方案1】:

    clipBehaviour 添加到堆栈

    Stack(
      clipBehaviour: Clip.none,
      children: <Widget>[
    ]
    ),
    

    这将强制它不剪切任何溢出的内容

    【讨论】:

      猜你喜欢
      • 2015-06-18
      • 2011-06-05
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多