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

aks*_*ksn 5 flutter flutter-layout

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

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

Rém*_*let 17

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

Stack(
  children: [
    Card(),
    Positioned.fill(
      child: Container(color: Colors.red),
    )
  ]
);
Run Code Online (Sandbox Code Playgroud)


kul*_*der 12

height: double.infinity 
Run Code Online (Sandbox Code Playgroud)

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