I need an AlertDialog
with minHeight
of 50
. It contains a ListView
. If the ListView
exceeds the screen it should become scrollable
. But I can't scroll for some reason. Can anyone explain to me why it's not working :)
AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: ... ,
content: ConstrainedBox(
constraints: new BoxConstraints(
minHeight: 50,
),
child: Column(
children: <Widget>[
Row(...),
Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: list.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () => _onTap(list[index]),
child: Row(
children: <Widget>[
Flexible(
flex: 1,
child: Checkbox(...),
),
Flexible(
flex: 3,
child: Text(list[index]),)
],
)
);
},
)
)
],
),
),
actions: <Widget>[
MaterialButton(
minWidth:100,
child: Text('Cancel'),
onPressed: (){
Navigator.of(context).pop();
}
),
MaterialButton(
minWidth:100,
elevation: 5.0,
color: Theme.of(context).accentColor,
child: Text('Save', style: TextStyle(color: Color(0xFFF6F5F5))),
onPressed: (){
}
)
],
);
Add mainAxisSize: MainAxisSize.min to your Column. Without it, your Column is at infinite height and contains all Listview items. That's why it does not scroll.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.