我有一个扩展磁贴,当它扩展以显示我的小部件并使其大小动态适应孩子的大小时,我喜欢它,所以我尝试了这个:
ExpansionTile(
maintainState: true,
tilePadding: EdgeInsets.all(15.0),
title: Text(
'${color.id}',
style: Theme.of(context)
.textTheme
.subtitle1
.copyWith(fontWeight: FontWeight.w600),
),
childrenPadding: EdgeInsets.all(10.0),
children: [
Flexible(
child: Column(
children: [
...colors.types.map<Widget>(
(item) {
return Expanded(
child: ListView(
scrollDirection: Axis.horizontal,
children: [
...item.prices.map<Widget>((size) {
return Row(
children: [
Column(
children: [
MyWidget(
color: color,
size: size
),
],
)
],
);
}),
],
)
);
}
),
],
)
)
]
);
但是抛出这个错误:
<块引用>RenderFlex 子级具有非零 flex,但传入的高度约束是无界的。
如果我用 MediaQuery.of(context).size.height 放置一个容器而不是一个灵活的,它可以很好地显示小部件但填满整个屏幕,我想要的是具有显示子项所需大小的容器。我必须做什么?
答案 0 :(得分:0)
你可以试试 MediaQuery.of(context).size.height / x。弄清楚您需要多少空间并将其分配到容器的高度。该容器可以包含可滚动列表,但会防止 renderflex 错误。