alert function

void alert(
  1. BuildContext context, {
  2. double? top,
  3. double? left,
  4. double? right,
  5. double? height,
  6. double? heightSpacing = 4,
  7. SFAlertStatus status = SFAlertStatus.primary,
  8. required String title,
  9. Widget? titleLeading,
  10. Widget? closeWidget,
  11. TextStyle? titleTextStyle,
  12. required String content,
  13. EdgeInsets? padding,
  14. TextStyle? contentTextStyle,
  15. Color? backgroundColor,
  16. Color? borderColor,
  17. BorderRadius? borderRadius,
})

Implementation

void alert(
  BuildContext context, {
  double? top,
  double? left,
  double? right,
  double? height,
  double? heightSpacing = 4,
  SFAlertStatus status = SFAlertStatus.primary,
  required String title,
  Widget? titleLeading,
  Widget? closeWidget,
  TextStyle? titleTextStyle,
  required String content,
  EdgeInsets? padding,
  TextStyle? contentTextStyle,
  Color? backgroundColor,
  Color? borderColor,
  BorderRadius? borderRadius,
}) {
  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) => SFAlert(
      top: top,
      left: left,
      right: right,
      height: height,
      heightSpacing: heightSpacing,
      status: status,
      title: title,
      titleLeading: titleLeading,
      closeWidget: closeWidget,
      titleTextStyle: titleTextStyle,
      content: content,
      padding: padding,
      contentTextStyle: contentTextStyle,
      backgroundColor: backgroundColor,
      borderColor: borderColor,
      borderRadius: borderRadius,
      onTap: () {
        overlayEntry?.remove();
      },
    ),
  );
  overlayState.insert(overlayEntry);
}