notificationDialog function
Notification dialog Shows a notification dialog with given title and message
Implementation
Future<bool> notificationDialog(
BuildContext buildContext,
String title,
String message, {
Widget? titleMessage,
Widget? contentMessage,
Widget? closeButtonText,
Widget? goToButtonText,
Function? onTap,
String? path,
Color? flashBackgroundColor,
Color? closeDialogButtonColor,
Color? goToDialogButtonColor,
}) async {
try {
return (await showFlash(
context: buildContext,
duration: const Duration(seconds: 5),
builder: (context, controller) {
return Flash(
controller: controller,
position: FlashPosition.bottom,
child: GestureDetector(
onTap: () {
if (onTap != null) onTap();
},
child: FlashBar(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
behavior: FlashBehavior.floating,
margin: const EdgeInsets.all(20),
backgroundColor: flashBackgroundColor ?? Colors.blue[800],
title: titleMessage ??
Text(
title,
style:
const TextStyle(color: Colors.white, fontSize: 25),
),
content: contentMessage ??
Text(
message,
style: const TextStyle(
color: Colors.white70, fontSize: 20),
),
controller: controller,
),
),
);
},
) as bool?) ??
false;
} catch (err) {
if (kDebugMode) {
print(err);
}
return await showDialog<bool>(
context: buildContext,
barrierDismissible: true,
builder: (BuildContext context) {
return SimpleDialog(
title: titleMessage ?? Text(title),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
children: <Widget>[
Padding(
padding: const EdgeInsets.all(15.0),
child: contentMessage ??
Text(
message,
style: TextStyle(
color: Colors.blueGrey[600], fontSize: 15),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
color: closeDialogButtonColor ?? Colors.blue[800],
child: TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: closeButtonText ??
const Text(
"OK",
style: TextStyle(
color: Colors.white, fontSize: 18),
),
),
),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Card(
color: goToDialogButtonColor ?? Colors.green[700],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
child: TextButton(
onPressed: () {
if (onTap != null) onTap();
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: goToButtonText ??
const Text(
"Go",
style: TextStyle(
color: Colors.white, fontSize: 18),
),
),
),
),
),
],
),
],
);
},
) ??
false;
}
}