showSKAlert function

Future<bool?> showSKAlert(
  1. Widget msg, {
  2. Widget? title,
  3. Widget? confirmText,
  4. Widget? cancelText,
  5. bool isCancelable = true,
  6. BuildContext? context,
  7. BuildContextPredicate buildContextPredicate = _defaultContextPredicate,
})

Implementation

Future<bool?> showSKAlert(
  Widget msg, {
  Widget? title,
  Widget? confirmText,
  Widget? cancelText,
  bool isCancelable = true,
  BuildContext? context,
  BuildContextPredicate buildContextPredicate = _defaultContextPredicate,
}) {
  if (context == null) {
    _throwIfNoContext(_contextMap.values, 'showAlert');
  }
  context ??= buildContextPredicate(_contextMap.values);

  return showDialog<bool>(
    context: context,
    barrierDismissible: isCancelable,
    builder: (context) => AlertDialog(
      content: msg,
      title: title,
      actions: [
        TextButton(
            onPressed: () {
              Navigator.pop(context, true);
            },
            child: confirmText ?? const Text("OK")),
        TextButton(
            onPressed: () {
              Navigator.pop(context, false);
            },
            child: cancelText ?? const Text("Cancel"))
      ],
    ),
  );
}