颤振容器高度与父高度相同 [英] Flutter Container height same as parent height
本文介绍了颤振容器高度与父高度相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用白色容器覆盖卡片,但是容器总是需要一个高度(否则它不会显示).我希望它和它的父堆栈一样大.我该如何进行这项工作?卡的高度会有所不同.我想我缺少了一些;)
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),
]
);
推荐答案
您可以使用Positioned.fill
强制堆栈子项填充Stack
.
You can use a Positioned.fill
to force a stack child to fill Stack
.
Stack(
children: [
Card(),
Positioned.fill(
child: Container(color: Colors.red),
)
]
);
这篇关于颤振容器高度与父高度相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文