How to create a Dialog in Flutter? Will we able to create a Dialog with Close Button in Flutter? Yes we can create a Dialog in a flutter with showGeneralDialog() widget. With below code we can create an Alert Dialog
AlertDialog(
backgroundColor:Colors.white,
shape: _defaultShape(),
insetPadding: EdgeInsets.all(8),
elevation: 10,
titlePadding: const EdgeInsets.all(0.0),
title: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_getCloseButton(context),
Padding(
padding: EdgeInsets.fromLTRB(
20,10, 20, 0),
child: Column(
children: <Widget>[
Icon(Icons.warning_amber_sharp,size: 48,),
SizedBox(
height: 15,
),
Text(
"Alert with Close Button",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.normal),
textAlign: TextAlign.center,
),
SizedBox(
height: 10,
),
Text(
"Your Subscription Plan Expiered",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontStyle: FontStyle.normal),
textAlign: TextAlign.center,
),
SizedBox(
height: 20,
),
],
),
)
],
),
),
),
contentPadding: EdgeInsets.all(8),
content: buttonsRowDirection==1
? Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: _getRowButtons(context),
)
: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: _getColButtons(context),
));
}
TO add Close Button to Alert Dialog please refer Close Button
Comments (0)