showCupertinoAlert static method

dynamic showCupertinoAlert(
  1. BuildContext context, {
  2. String title = "提示",
  3. String? detailTitle,
  4. dynamic trueFunction()?,
  5. dynamic cancelFunction()?,
})

Implementation

static showCupertinoAlert(BuildContext context,
    {String title = "提示",
    String? detailTitle,
    Function()? trueFunction,
    Function()? cancelFunction}) {
  return showCupertinoDialog(
      context: context,
      builder: (context) {
        return CupertinoAlertDialog(
          title: Text(title),
          content: detailTitle != null ? Text(detailTitle) : null,
          actions: cancelFunction != null
              ? [
                  CupertinoDialogAction(
                    child: Text('确认'),
                    onPressed: () {
                      if (trueFunction != null) trueFunction();
                    },
                  ),
                  CupertinoDialogAction(
                    child: Text('取消'),
                    isDestructiveAction: true,
                    onPressed: () {
                      if (cancelFunction != null) cancelFunction();
                    },
                  ),
                ]
              : [
                  CupertinoDialogAction(
                    child: Text('确认'),
                    onPressed: () {
                      if (trueFunction != null) trueFunction();
                    },
                  ),
                ],
        );
      });
}