![](/img/trans.png)
[英]How to give to a Flutter container the Height equivalent to the listview child inside himself
[英]How to give to a Flutter container the Height equivalent to the child and children inside himself
如何給容器高度提供與該容器內所有孩子相等的正確高度? 這是我的一段代碼:
child: Container(
height: ????,<----HERE TO BE IMPLEMENT HEIGHT
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 15,),
SearchWidget(),
Padding(
padding: const EdgeInsets.fromLTRB(12, 15, 0, 8),
child: Text('Le offerte del Momento',style: TextStyle(color: Color(0xff494949),fontWeight: FontWeight.w500),),
),
要獲取孩子的高度,請使用 IntrinsicHeight:
Container(
child: IntrinsicHeight(
child: Column(
...
但正如評論中所說,除非您需要 Container 的某些屬性,例如裝飾,否則不應使用 Container,因為在這種情況下它是無用的。 只需將mainAxisSize: MainAxisSize.min
添加到您的列中,以便其大小取決於孩子的大小。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.