alertDialog function
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,
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);
}