13

我想用白色容器覆盖卡片,但容器总是需要一个高度(否则它不会显示)。我希望它和它的父级堆栈一样大。我怎样才能使这项工作?卡的高度不同。我想我错过了一些东西;)

return new Stack(
 children: <Widget>[
  new Card( ... ),
  new Container(color: Colors.white70),
 ]
);
4

2 回答 2

51

您可以使用 aPositioned.fill强制堆栈子级填充Stack

Stack(
  children: [
    Card(),
    Positioned.fill(
      child: Container(color: Colors.red),
    )
  ]
);
于 2018-06-28T09:33:15.637 回答
13
height: double.infinity 

在容器的情况下它对我有用

于 2020-03-05T08:47:25.803 回答