import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; Future showAlertDialog({ BuildContext context, @required String title, @required String contentMessage, String confirmText, String cancelText, }) { return showDialog( context: context, builder: (context) { return AlertDialog( title: Text(title), content: Text(contentMessage), actions: [ if (cancelText != null) TextButton( onPressed: () { Navigator.of(context).pop(false); }, child: Text(cancelText), ), TextButton( onPressed: () { Navigator.of(context).pop(true); }, child: Text(confirmText), ), ], ); }, ); }