当给定尺寸大于父级时,如何创建与父级同胞重叠的小部件?

时间:2019-03-20 13:12:07

标签: flutter

我知道想到的第一个答案是OverflowBox,但是溢出框的问题在于,该子对象被放置在视图层次结构中首先出现的同级对象上,但随后出现的小部件覆盖了溢出框。 例如-以下代码

body: Center(
    child: ListView(
      children: <Widget>[
        Container(
          color: Colors.red,
          height: 200,
        ),
        Container(
          color: Colors.blue,
          height: 200,
          child: OverflowBox(
            maxWidth: 1000,
            maxHeight: 1000,
            child: Container(
              height: 800,
              color: Colors.yellow,
            ),
          ),
        ),
        Container(
          color: Colors.red,
          height: 200,
        ),
      ],
    ),

采用以下布局

enter image description here

但是我也希望黄色容器也能覆盖红色容器。我知道一个可能的原因是红色容器涂在黄色容器之后。另外,我还需要一种无需更改同级或父级属性的解决方案。仅允许对蓝色容器的子项进行更改。

0 个答案:

没有答案