未将Flutter子项放置在堆栈小部件中时,该子项隐藏在另一个子项下

时间:2019-07-22 22:39:03

标签: flutter dart widget

我试图将带有文本的容器放在Stack子项之外,但它仍位于堆栈中其他子项的下面。我该如何解决?

import

1 个答案:

答案 0 :(得分:0)

I tested your code.

Container(
    height: 150,
    child: ListView(
      scrollDirection: Axis.horizontal,
      children: <Widget>[
        Container(
          margin: EdgeInsets.only(bottom: 10.0),
          height: 80.0,
          child: Stack(
            alignment: Alignment.center,
            children: <Widget>[
              Container(
                height: 800,
                width: 370,
                decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(250.0))),
                child: Image(
                  image: AssetImage("assets/images/intro_0.jpg"),
                  fit: BoxFit.fill,
                ),
              ),
              Container(
                child: Row(
                  children: <Widget>[
                    Text("New Look")
                  ],
                ),
              ),
              Positioned(
                bottom: 60,
                left: 65.0,
                child: Row(
                  children: <Widget>[
                    Text("NEW LOOK", style: TextStyle(color: Colors.cyan, fontSize: 35.0),)
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  )

堆栈的子级中的小部件按书写顺序显示。堆栈的大小是第一个小部件,然后添加的小部件依次叠加在顶层。

enter image description here