showActionDialog method

Future<ActionDialogOptions> showActionDialog(
  1. BuildContext context,
  2. String dialogTitle,
  3. String dialogContent,
  4. String actionButtonText,
)

Implementation

Future<ActionDialogOptions> showActionDialog(
  BuildContext context,
  String dialogTitle,
  String dialogContent,
  String actionButtonText,
) async {
  var result = await showDialog<ActionDialogOptions>(
    context: context,
    builder: (context) {
      return AlertDialog(
        title: Text(dialogTitle),
        content: Text(dialogContent),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.of(context).pop(ActionDialogOptions.cancel);
            },
            child: const Text('Cancel'),
          ),
          FilledButton(
            onPressed: () {
              Navigator.of(context).pop(ActionDialogOptions.action);
            },
            child: Text(actionButtonText),
          ),
        ],
      );
    },
  );

  return result ?? ActionDialogOptions.cancel;
}