confirm method

Future<bool> confirm({
  1. required BuildContext context,
  2. Widget? content,
  3. Widget? title,
  4. bool defaultValue = false,
})

Implementation

Future<bool> confirm({
  required BuildContext context,
  Widget? content,
  Widget? title,
  bool defaultValue = false,
}) async {
  var locale = MaterialLocalizations.of(context);
  var nav = navigator(context);
  return await withChild(AlertDialog(
        title: title,
        content: Padding(
          padding: const EdgeInsets.all(8),
          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) ??
      defaultValue;
}