Initial commit
This commit is contained in:
59
lib/core/utils/dialogs.dart
Normal file
59
lib/core/utils/dialogs.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
Future<
|
||||
bool
|
||||
>
|
||||
showYesNoDialog(
|
||||
BuildContext context, {
|
||||
String close = 'Close',
|
||||
String accept = 'Accept',
|
||||
String title = '',
|
||||
String message = '',
|
||||
VoidCallback? actionClose,
|
||||
VoidCallback? actionOk,
|
||||
}) async {
|
||||
final result =
|
||||
await showCupertinoDialog<
|
||||
bool
|
||||
>(
|
||||
context: context,
|
||||
builder:
|
||||
(
|
||||
BuildContext context,
|
||||
) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(
|
||||
title,
|
||||
),
|
||||
content: Text(
|
||||
message,
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () => Navigator.pop(
|
||||
context,
|
||||
false,
|
||||
),
|
||||
child: Text(
|
||||
close,
|
||||
),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(
|
||||
context,
|
||||
true,
|
||||
),
|
||||
child: Text(
|
||||
accept,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return result ??
|
||||
false; // false if dismissed
|
||||
}
|
||||
Reference in New Issue
Block a user