showConfirmDialog function

Future<bool> showConfirmDialog(
  1. BuildContext context, {
  2. required String message,
})

Implementation

Future<bool> showConfirmDialog(
  BuildContext context, {
  required String message,
}) async {
  final response = await showDialog<bool>(
    context: context,
    builder: (context) {
      return AlertDialog(
        title: const Text("안내"),
        content: Text(message),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.of(context).pop(true);
            },
            child: const Text("확인"),
          ),
          TextButton(
            onPressed: () {
              Navigator.of(context).pop(false);
            },
            child: const Text("취소"),
          ),
        ],
      );
    },
  );

  if (response == true) {
    return true;
  }

  return false;
}