showAlertDialog static method
Show a dialog with title prefs.title
,
message prefs.message
,
and someone other things.
Implementation
static showAlertDialog(BuildContext context,
{required NkAlertDialogPrefs prefs}) {
if (_isShowed) return;
Widget okButton = NkFlatButton(
prefs.okButtonText,
height: 40,
width: 50,
textStyle: prefs.okButtonStyle == null
? TextStyle(fontSize: 18)
: prefs.okButtonStyle!.merge(TextStyle(fontSize: 18)),
onClick: hideLoading(context),
);
_isShowed = true;
showDialog(
context: context,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async {
_isShowed = false;
return true;
},
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Material(
color: Colors.transparent,
child: Center(
child: Container(
padding: EdgeInsets.fromLTRB(20, 20, 10, 10),
height: constraints.maxHeight * .25,
width: constraints.maxWidth * .7,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(prefs.title,
style: prefs.titleStyle == null
? TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold)
: prefs.titleStyle!.merge(TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold))),
Padding(
padding: const EdgeInsets.only(top: 10),
child: Text(prefs.message,
style: prefs.messageStyle == null
? TextStyle(fontSize: 18)
: prefs.messageStyle!
.merge(TextStyle(fontSize: 18))),
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [okButton],
)
],
),
)));
},
),
);
},
);
}