[英]Flutter, how can i set the height of list of items with flexible height with max height 300?
: Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColorDark,
borderRadius:
BorderRadius.all(Radius.circular(10))),
***constraints: BoxConstraints(
maxHeight: 300,
minHeight: 170,
),***
width: double.infinity,
padding: EdgeInsets.all(8),
margin: EdgeInsets.only(left: 16, right: 16),
child: Column(
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(
'Select Branch',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 8,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
'Number of branches = ${_branches.length}',
style: TextStyle(
color: Colors.grey, fontSize: 10),
),
),
),
SizedBox(
height: 16,
),
Expanded(
child: ListView.builder(
itemCount: _branches.length,
itemBuilder: (ctx, i) {
return GestureDetector(
....
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(12),
),
color:
Theme.of(context).backgroundColor,
child: Container(
padding: EdgeInsets.all(20),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
_branches[i]
.branchDistrict
.name,
style: TextStyle(
color: Colors.white,
fontSize: 16),
),
(_selectedBranchChecked == i)
? Container(
height: 40,
width: 40,
child: Image.asset(
getAssetsName(
AssetsImage
.checkIcon),
fit: BoxFit.cover,
),
)
: Container(
padding: EdgeInsets.only(
top: 5, bottom: 5),
height: 40,
width: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: SizedBox(),
),
],
),
),
),
);
},
),
),
],
),
)
添加到容器屬性mainAxisSize: MainAxisSize.min
中的 Column 中,我敢打賭你必須在這里刪除Expanded
小部件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.