Reputation: 303
I Have an Alert dialog menu which contain a grid view containing some button, I need my Alert dialog to be shown on bottom of page not in the middle. My question is how to do it.
Widget _buildAboutDialog(BuildContext context) {
return new AlertDialog(
backgroundColor: Colors.black,
content: Container(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.25,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: new GridView.count(
crossAxisCount: 4,
children: new List<Widget>.generate(8, (index) {
return new GridTile(
child: new Card(
color: Colors.blue.shade200,
child: new Center(
child: new Text('$index'),
)
)
);
})),
) ],
),),
);
}
}
Upvotes: 0
Views: 2918
Reputation: 1659
Maybe you shouldn't use the alert dialog and instead show a dialog with your own widget.
Do note that i'm a bit puzzled if you need a dialog at all. If you don't need a dialog attached is some methods that may hopefully help.
If you just need a widget:
Widget bottomGridTiles(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
GridView.count(
shrinkWrap: true, // Important
crossAxisCount: 4,
children: List<Widget>.generate(8, (index) {
return GridTile(
child: Card(
color: Colors.blue.shade200,
child: Center(
child: Text('$index'),
)));
}))
],
);
}
If you need a dialog with the widget:
void _buildDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return bottomGridTiles(context);
});
}
Widget that opens the dialog:
Widget openDialogButton(BuildContext context) {
return RaisedButton(
onPressed: () => _buildDialog,
child: Text("Open Dialog"),
);
}
Upvotes: 3