ShadDialog class

A customizable dialog widget for displaying content and actions.

The ShadDialog widget provides a styled container for presenting a title, description, custom content, and actions in a modal format. It supports variants (primary and alert) and integrates with ShadTheme for styling. Use named constructors like ShadDialog.alert for alert-specific styling or ShadDialog.raw for full control.

Inheritance
Available extensions

Constructors

ShadDialog({Key? key, Widget? title, Widget? description, Widget? child, List<Widget> actions = const [], Widget? closeIcon, IconData? closeIconData, ShadPosition? closeIconPosition, BorderRadius? radius, Color? backgroundColor, bool? expandActionsWhenTiny, EdgeInsetsGeometry? padding, double? gap, BoxConstraints? constraints, BoxBorder? border, List<BoxShadow>? shadows, bool? removeBorderRadiusWhenTiny, Axis? actionsAxis, MainAxisSize? actionsMainAxisSize, MainAxisAlignment? actionsMainAxisAlignment, VerticalDirection? actionsVerticalDirection, TextStyle? titleStyle, TextStyle? descriptionStyle, TextAlign? titleTextAlign, TextAlign? descriptionTextAlign, Alignment? alignment, MainAxisAlignment? mainAxisAlignment, CrossAxisAlignment? crossAxisAlignment, bool? scrollable, EdgeInsetsGeometry? scrollPadding, double? actionsGap, bool? useSafeArea, bool? titlePinned, bool? descriptionPinned, bool? actionsPinned})
Creates a primary variant dialog widget.
const
ShadDialog.alert({Key? key, Widget? title, Widget? description, Widget? child, List<Widget> actions = const [], Widget? closeIcon, IconData? closeIconData, ShadPosition? closeIconPosition, BorderRadius? radius, Color? backgroundColor, bool? expandActionsWhenTiny, EdgeInsetsGeometry? padding, double? gap, BoxConstraints? constraints, BoxBorder? border, List<BoxShadow>? shadows, bool? removeBorderRadiusWhenTiny, Axis? actionsAxis, MainAxisSize? actionsMainAxisSize, MainAxisAlignment? actionsMainAxisAlignment, VerticalDirection? actionsVerticalDirection, TextStyle? titleStyle, TextStyle? descriptionStyle, TextAlign? titleTextAlign, TextAlign? descriptionTextAlign, Alignment? alignment, MainAxisAlignment? mainAxisAlignment, CrossAxisAlignment? crossAxisAlignment, bool? scrollable, EdgeInsetsGeometry? scrollPadding, double? actionsGap, bool? useSafeArea, bool? titlePinned, bool? descriptionPinned, bool? actionsPinned})
Creates an alert variant dialog widget, typically for warnings or critical messages.
const
ShadDialog.raw({Key? key, required ShadDialogVariant variant, Widget? title, Widget? description, Widget? child, List<Widget> actions = const [], Widget? closeIcon, IconData? closeIconData, ShadPosition? closeIconPosition, BorderRadius? radius, Color? backgroundColor, bool? expandActionsWhenTiny, EdgeInsetsGeometry? padding, double? gap, BoxConstraints? constraints, BoxBorder? border, List<BoxShadow>? shadows, bool? removeBorderRadiusWhenTiny, Axis? actionsAxis, MainAxisSize? actionsMainAxisSize, MainAxisAlignment? actionsMainAxisAlignment, VerticalDirection? actionsVerticalDirection, TextStyle? titleStyle, TextStyle? descriptionStyle, TextAlign? titleTextAlign, TextAlign? descriptionTextAlign, Alignment? alignment, MainAxisAlignment? mainAxisAlignment, CrossAxisAlignment? crossAxisAlignment, bool? scrollable, EdgeInsetsGeometry? scrollPadding, double? actionsGap, bool? useSafeArea, bool? titlePinned, bool? descriptionPinned, bool? actionsPinned})
Creates a dialog widget with a specified variant, offering full customization.
const

Properties

actions List<Widget>
The list of action widgets displayed at the bottom of the dialog. Typically buttons, arranged based on actionsAxis. Defaults to an empty list if not specified.
final
actionsAxis Axis?
The axis along which actions are arranged (horizontal or vertical). Responsive to screen size if not specified.
final
actionsGap double?
The gap between action buttons. Defaults to 8 if not specified.
final
actionsMainAxisAlignment MainAxisAlignment?
The main axis alignment of the actions. Defaults to MainAxisAlignment.end if not specified.
final
actionsMainAxisSize MainAxisSize?
The main axis size of the actions layout. Defaults to MainAxisSize.max if not specified.
final
actionsPinned bool?
Whether the actions are pinned when scrolling and scrollable is true.
final
actionsVerticalDirection VerticalDirection?
The vertical direction of the actions layout when vertical. Responsive to screen size if not specified.
final
alignment Alignment?
The alignment of the dialog within its parent container. Defaults to Alignment.center if not specified.
final
backgroundColor Color?
The background color of the dialog. Defaults to the theme’s background color if not specified.
final
border BoxBorder?
The border surrounding the dialog. Defaults to a border with the theme’s border color if not specified.
final
child Widget?
The main content widget of the dialog, displayed below the description. Expands to fill available space if scrollable.
final
closeIcon Widget?
The custom widget for the close button. Overrides closeIconData if provided; defaults to a ghost button with an 'X' icon.
final
closeIconData IconData?
The icon data for the close button. Used if closeIcon is null; defaults to LucideIcons.x if not specified.
final
closeIconPosition ShadPosition?
The position of the close icon within the dialog. Defaults to top-end (8, 8) if not specified.
final
constraints BoxConstraints?
Constraints applied to the dialog’s layout. Defaults to a max width of 512 if not specified.
final
crossAxisAlignment CrossAxisAlignment?
The cross axis alignment of the dialog’s column content. Defaults to CrossAxisAlignment.start if not specified.
final
description Widget?
The description widget displayed below the title. Typically a Text widget, styled with the theme’s muted style.
final
descriptionPinned bool?
Whether the description is pinned when scrolling and scrollable is true.
final
descriptionStyle TextStyle?
The text style for the description. Defaults to the theme’s muted text style if not specified.
final
descriptionTextAlign TextAlign?
The text alignment for the description. Responsive to screen size if not specified.
final
expandActionsWhenTiny bool?
Whether actions expand to full width on small screens. Defaults to true if not specified.
final
gap double?
The gap between content elements (title, description, child, actions). Defaults to 8 if not specified.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
mainAxisAlignment MainAxisAlignment?
The main axis alignment of the dialog’s column content. Defaults to MainAxisAlignment.start if not specified.
final
padding EdgeInsetsGeometry?
The padding inside the dialog, surrounding all content. Defaults to EdgeInsets.all(24) if not specified.
final
radius BorderRadius?
The border radius of the dialog’s corners. Defaults to the theme’s radius if not specified.
final
removeBorderRadiusWhenTiny bool?
Whether to remove the border radius on small screens. Defaults to true if not specified.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollable bool?
Whether the dialog content is scrollable.
final
scrollPadding EdgeInsetsGeometry?
The padding applied when the dialog content is scrollable.
final
shadows List<BoxShadow>?
The list of box shadows applied to the dialog for elevation. Defaults to large shadows if not specified.
final
title Widget?
The title widget displayed at the top of the dialog. Typically a Text widget, styled with the theme’s large text style.
final
titlePinned bool?
Whether the title is pinned when scrolling and scrollable is true.
final
titleStyle TextStyle?
The text style for the title. Defaults to the theme’s large text style if not specified.
final
titleTextAlign TextAlign?
The text alignment for the title. Responsive to screen size if not specified.
final
useSafeArea bool?
Whether to wrap the dialog in a SafeArea widget to avoid system UI intrusions.
final
variant ShadDialogVariant
The variant of the dialog, either ShadDialogVariant.primary or ShadDialogVariant.alert. Determines the visual style applied through the ShadTheme.
final

Methods

animate({Key? key, List<Effect>? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) Animate

Available on Widget, provided by the AnimateWidgetExtensions extension

Wraps the target Widget in an Animate instance, and returns the instance for chaining calls. Ex. myWidget.animate() is equivalent to Animate(child: myWidget).
build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
positionedWith(ShadPosition position) Widget

Available on Widget, provided by the PositionedExt extension

toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited