Flutter 容器高度与父高度相同 [英] Flutter Container height same as parent height
本文介绍了Flutter 容器高度与父高度相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用白色容器覆盖卡片,但容器始终需要高度(否则不会显示).我希望它和它的父级堆栈一样大.我怎样才能使这项工作?卡的高度不同.我想我错过了什么;)
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),
)
]
);
这篇关于Flutter 容器高度与父高度相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文