Flutter Container height same as parent height

不羁岁月 提交于 2019-12-22 06:37:09

问题


I want to overlay a Card with a white container, but the container always needs a height (otherwise it's not displayed). I want it to be as big as its parent, the stack. How can I make this work? The height of the card varies. I guess I'm missing something ;)

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

回答1:


You can use a Positioned.fill to force a stack child to fill Stack.

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


来源:https://stackoverflow.com/questions/51078707/flutter-container-height-same-as-parent-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!