confirm method

Future<bool> confirm({
  1. BuildContext? context,
  2. Widget? content,
  3. Widget? title,
  4. Widget? icon,
  5. bool cancel = false,
  6. EdgeInsetsGeometry padding = const EdgeInsets.all(8),
})

Implementation

Future<bool> confirm({
  BuildContext? context,
  Widget? content,
  Widget? title,
  Widget? icon,
  bool cancel = false,
  EdgeInsetsGeometry padding = const EdgeInsets.all(8),
}) async {
  var locale = MaterialLocalizations.of(context ?? this.context!);
  var nav = navigator(context);
  return await withChild(
        AlertDialog(
          title: title,
          icon: icon,
          content: Padding(padding: padding, child: content),
          actions: [
            TextButton(
              onPressed: () => nav.pop(true),
              child: Text(locale.okButtonLabel),
            ),
            TextButton(
              onPressed: () => nav.pop(false),
              child: Text(locale.cancelButtonLabel),
            ),
          ],
        ),
      ).prompt<bool>(context: context) ??
      cancel;
}