success static method
void
success({
- String svgAssetDir = 'assets/images/ic_dialog_success.svg',
- bool showAsset = true,
- String title = 'Success',
- double titleTextSize = 18,
- TextAlign titleTextAlign = TextAlign.left,
- Color titleTextColor = Colors.black,
- String message = '',
- double messageTextSize = 14,
- TextAlign messageTextAlign = TextAlign.left,
- Color messageTextColor = const Color(0xff596066),
- bool isDismissible = false,
- String btnOkText = 'Close',
- Color? barrierColor = Colors.black54,
- double cornerRadius = 4.0,
- Widget? additional,
- dynamic onYes()?,
-- example implementation --
ExAlert.success(
context: Get.context!,
title: 'Hello World',
message: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
onYes: () => print('clicked'),
);
Implementation
static void success({
String svgAssetDir = 'assets/images/ic_dialog_success.svg',
bool showAsset = true,
String title = 'Success',
double titleTextSize = 18,
TextAlign titleTextAlign = TextAlign.left,
Color titleTextColor = Colors.black,
String message = '',
double messageTextSize = 14,
TextAlign messageTextAlign = TextAlign.left,
Color messageTextColor = const Color(0xff596066),
bool isDismissible = false,
String btnOkText = 'Close',
Color? barrierColor = Colors.black54,
double cornerRadius = 4.0,
Widget? additional,
Function()? onYes,
}) {
showDialog(
context: Get.context!,
barrierDismissible: isDismissible,
barrierColor: barrierColor,
builder: (context) {
return WillPopScope(
onWillPop: () async => isDismissible,
child: AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(cornerRadius))),
// contentPadding: EdgeInsets.all(16),
scrollable: true,
content: VStack([
if (showAsset)
VStack([
if (svgAssetDir.isNotBlank)
SvgPicture.asset(svgAssetDir, width: 90, height: 90).centered()
else
SvgPicture.asset(svgAssetDir, package: 'gredu_common', width: 90, height: 90).centered(),
24.heightBox,
]),
Text(
title,
style: TextStyle(fontSize: titleTextSize, fontWeight: FontWeight.bold, color: titleTextColor),
textAlign: titleTextAlign,
maxLines: 2,
).w(double.infinity),
12.heightBox,
Text(
message,
style: TextStyle(fontSize: messageTextSize, fontWeight: FontWeight.normal, color: messageTextColor, height: 1.5),
textAlign: messageTextAlign,
).w(double.infinity),
additional ?? 0.heightBox,
]),
actions: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Theme.of(context).primaryColor),
onPressed: onYes ?? () => Get.back(),
child: Text(btnOkText),
).pOnly(left: 12, right: 12, bottom: 12).h(55).expand(),
],
),
],
),
);
},
);
}