alertDialog function

void alertDialog(
  1. BuildContext context, {
  2. double? top,
  3. double? left,
  4. double? right,
  5. double? height,
  6. double? titleAndContentsSpacing = 4,
  7. required String title,
  8. Widget? titleLeading,
  9. TextStyle? titleTextStyle,
  10. required String content,
  11. EdgeInsets? padding,
  12. TextStyle? contentTextStyle,
  13. Color? backgroundColor,
  14. Color? borderColor,
  15. BorderRadius? borderRadius,
  16. String? cancleButtonText,
  17. String? acceptButtonText,
  18. VoidCallback? onCancle,
  19. VoidCallback? onAccept,
})

Implementation

void alertDialog(
  BuildContext context, {
  double? top,
  double? left,
  double? right,
  double? height,
  double? titleAndContentsSpacing = 4,
  required String title,
  Widget? titleLeading,
  TextStyle? titleTextStyle,
  required String content,
  EdgeInsets? padding,
  TextStyle? contentTextStyle,
  Color? backgroundColor,
  Color? borderColor,
  BorderRadius? borderRadius,
  String? cancleButtonText,
  String? acceptButtonText,
  VoidCallback? onCancle,
  VoidCallback? onAccept,
}) {
  if (top != null && (top < 0.0 || top > 1.0)) {
    throw ArgumentError('top value must be between 0.0 and 1.0');
  }
  OverlayState overlayState = Overlay.of(context);
  OverlayEntry? overlayEntry;
  overlayEntry = OverlayEntry(
    builder: (context) => SFAlertDialog(
      top: top,
      left: left,
      right: right,
      height: height,
      titleAndContentsSpacing: titleAndContentsSpacing,
      title: title,
      titleLeading: titleLeading,
      titleTextStyle: titleTextStyle,
      content: content,
      padding: padding,
      contentTextStyle: contentTextStyle,
      backgroundColor: backgroundColor,
      borderColor: borderColor,
      borderRadius: borderRadius,
      remove: () {
        overlayEntry?.remove();
      },
      acceptButtonText: acceptButtonText,
      cancleButtonText: cancleButtonText,
      onAccept: onAccept,
      onCancle: onCancle,
    ),
  );
  overlayState.insert(overlayEntry);
}