baseDialog function
Displays a custom dialog with optional styling and animations.
content
is the body of the dialog.
dismissible
allows tapping outside to dismiss.
barrierColor
sets the background dim color.
backgroundColor
sets the dialog's background.
width
sets a custom width for the dialog.
dialogWidth
is the default dialog width if width
is not provided.
dialogRadius
sets the dialog corner radius.
dialogElevation
sets the elevation of the dialog.
Implementation
Future<void> baseDialog(
BuildContext context, {
required Widget content,
bool dismissible = true,
Color? barrierColor = Colors.black54,
Color? backgroundColor = Colors.white,
double? width,
double? dialogWidth = 280,
double dialogRadius = 8.0,
double dialogElevation = 10.0,
}) {
return showDialogWithAnimation<void>(
barrierDismissible: dismissible,
barrierColor: barrierColor,
context: context,
child: Dialog(
clipBehavior: Clip.hardEdge,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(dialogRadius)),
),
elevation: dialogElevation,
child: Container(
decoration: BoxDecoration(
color: backgroundColor,
),
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 16,
),
width: width ?? dialogWidth,
child: content,
),
),
);
}