Reputation: 308
I am struggling to make the alert dialogue box scrollable in Flutter. I have tried a few methods and so far this is the one that is working best:
Widget _buildPopupDialog(BuildContext context) {
List<IconData> _iconsTable = [
Icons.build,
Icons.format_paint,
Icons.assignment,
Icons.group_work,
Icons.home,
Icons.feedback,
...
];
return new AlertDialog(
title: const Text('Popup example'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Column(
children: new List.generate(26, (int index) {
return new Positioned(
child: new TableButtons(
iconData: _iconsTable[index]),
);
}),
),
],
),
),
],
),
Currently, the icons are showing up but it is not scrolling. The error message I am receiving is: "A RenderFlex overflowed by 170 pixels on the bottom." I think I have to use ListView but I am not sure where to add it as it is causing errors. Any help would be appreciated!
Upvotes: 1
Views: 1555
Reputation: 619
I think you have used unwanted Column()
widget.
Try this.
return AlertDialog(
title: const Text('Popup example'),
content: SingleChildScrollView(
child: new Column(
children: new List.generate(50, (int index) {
return new Positioned(
child: Icon(
Icons.camera
),
);
}),
),
),
);
Upvotes: 1
Reputation: 1084
You have to many Column containing only 1 child, so you must clean up a bit your code :
Widget _buildPopupDialog(BuildContext context) {
List<IconData> _iconsTable = [
Icons.build,
Icons.format_paint,
Icons.assignment,
Icons.group_work,
Icons.home,
Icons.feedback,
...
];
return new AlertDialog(
title: const Text('Popup example'),
content: SingleChildScrollView(
child: new Column(
children: new List.generate(26, (int index) {
return new Positioned(
child: new TableButtons(
iconData: _iconsTable[index]),
);
}),
),
),
Upvotes: 1