showPumaAlert function

dynamic showPumaAlert(
  1. BuildContext context, {
  2. String title = "",
  3. String message = "",
  4. String yes = "OK",
  5. String? no,
  6. void onYes()?,
  7. void onNo()?,
  8. Color yesColor = Colors.red,
  9. Color noColor = Colors.blue,
})

Implementation

showPumaAlert(
  BuildContext context, {
  String title = "",
  String message = "",
  String yes = "OK",
  String? no,
  void Function()? onYes,
  void Function()? onNo,
  Color yesColor = Colors.red,
  Color noColor = Colors.blue,
}) {
  var alert;

  if (Platform.isIOS) {
    alert = CupertinoAlertDialog(
      title: new Text(title),
      content: new Text(message),
      actions: [
        if (no != null)
          getCupertinoButton(no, noColor,
              onNo == null ? () => Navigator.of(context).pop() : onNo),
        getCupertinoButton(yes, yesColor, onYes!)
      ],
    );
  } else {
    alert = AlertDialog(
      title: Text(title),
      content: Text(message),
      actions: [
        if (no != null)
          getMaterialButton(no, noColor,
              onNo == null ? () => Navigator.of(context).pop() : onNo),
        getMaterialButton(yes, yesColor, onYes!),
      ],
    );
  }

  showDialog(
    context: context,
    builder: (BuildContext context) {
      return alert;
    },
  );
}