I have been trying to make a button in AlertDialog
box in Flutter. But I cannot find a way to stretch the button container. Please check my code and see the example picture below.
AlertDialog(
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: width,
//height: height,
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: image.url,
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);
Please help me in this. I am looking forward to hearing your opinion. Thank you in advance.
The
AlertDialog
has adefault content padding
of24
logical pixels to the right, left and bottom of theAlertDialog
to separate the content from the other edges of the dialog..To Make the
Button
fit theAlertDialog
width, you will need to give theAlertDialog
apadding
ofzero
and applypaddings
to others widgets except theButton
.I added an example using your code: