小编典典

颤振容器高度与父高度相同

flutter

我想用白色容器覆盖卡片,但是容器始终需要高度(否则它不会显示)。我希望它和它的父堆栈一样大。我该如何工作?卡的高度会有所不同。我想我想念什么;)

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

阅读 226

收藏
2020-08-13

共1个答案

小编典典

您可以使用Positioned.fill来强制堆栈子填充Stack

Stack(
  children: [
    Card(),
    Positioned.fill(
      child: Container(color: Colors.red),
    )
  ]
);
2020-08-13