show<T> method
OverlayCompleter<T>
show<T>({
- required BuildContext context,
- required AlignmentGeometry alignment,
- required WidgetBuilder builder,
- Offset? position,
- AlignmentGeometry? anchorAlignment,
- PopoverConstraint widthConstraint = PopoverConstraint.flexible,
- PopoverConstraint heightConstraint = PopoverConstraint.flexible,
- Key? key,
- bool rootOverlay = true,
- bool modal = true,
- bool barrierDismissable = true,
- Clip clipBehavior = Clip.none,
- Object? regionGroupId,
- Offset? offset,
- AlignmentGeometry? transitionAlignment,
- EdgeInsetsGeometry? margin,
- bool follow = true,
- bool consumeOutsideTaps = true,
- Anchor? anchor,
- ValueChanged<
PopoverOverlayWidgetState> ? onTickFollow, - bool allowInvertHorizontal = true,
- bool allowInvertVertical = true,
- bool dismissBackdropFocus = true,
- Duration? showDuration,
- Duration? dismissDuration,
- OverlayBarrier? overlayBarrier,
override
Shows an overlay with the specified configuration.
Displays an overlay (popover, sheet, or dialog) with extensive customization options for positioning, sizing, behavior, and appearance.
Parameters:
context(BuildContext, required): Build contextalignment(AlignmentGeometry, required): Overlay alignmentbuilder(WidgetBuilder, required): Overlay content builderposition(Offset?): Explicit position (overrides alignment)anchorAlignment(AlignmentGeometry?): Anchor alignmentwidthConstraint(PopoverConstraint): Width constraint, defaults to flexibleheightConstraint(PopoverConstraint): Height constraint, defaults to flexiblekey(Key?): Widget keyrootOverlay(bool): Use root overlay, defaults to truemodal(bool): Modal behavior, defaults to truebarrierDismissable(bool): Dismissible by tapping barrier, defaults to trueclipBehavior(Clip): Clipping behavior, defaults to noneregionGroupId(Object?): Region group IDoffset(Offset?): Position offsettransitionAlignment(AlignmentGeometry?): Transition alignmentmargin(EdgeInsetsGeometry?): Overlay marginfollow(bool): Follow anchor on move, defaults to trueconsumeOutsideTaps(bool): Consume outside taps, defaults to trueonTickFollow(ValueChanged<PopoverOverlayWidgetState>?): Follow tick callbackallowInvertHorizontal(bool): Allow horizontal inversion, defaults to trueallowInvertVertical(bool): Allow vertical inversion, defaults to truedismissBackdropFocus(bool): Dismiss on backdrop focus, defaults to trueshowDuration(Duration?): Show animation durationdismissDuration(Duration?): Dismiss animation durationoverlayBarrier(OverlayBarrier?): Custom barrier configurationanchor(Anchor?): Anchor to position/track against, defaults to a ContextAnchor wrappingcontext
Returns an OverlayCompleter for managing the overlay lifecycle.
Implementation
@override
OverlayCompleter<T> show<T>({
required BuildContext context,
required AlignmentGeometry alignment,
required WidgetBuilder builder,
Offset? position,
AlignmentGeometry? anchorAlignment,
PopoverConstraint widthConstraint = PopoverConstraint.flexible,
PopoverConstraint heightConstraint = PopoverConstraint.flexible,
Key? key,
bool rootOverlay = true,
bool modal = true,
bool barrierDismissable = true,
Clip clipBehavior = Clip.none,
Object? regionGroupId,
Offset? offset,
AlignmentGeometry? transitionAlignment,
EdgeInsetsGeometry? margin,
bool follow = true,
bool consumeOutsideTaps = true,
Anchor? anchor,
ValueChanged<PopoverOverlayWidgetState>? onTickFollow,
bool allowInvertHorizontal = true,
bool allowInvertVertical = true,
bool dismissBackdropFocus = true,
Duration? showDuration,
Duration? dismissDuration,
OverlayBarrier? overlayBarrier,
}) {
var navigatorState = Navigator.of(
context,
rootNavigator: rootOverlay,
);
final CapturedThemes themes =
InheritedTheme.capture(from: context, to: navigatorState.context);
final CapturedData data =
Data.capture(from: context, to: navigatorState.context);
var dialogRoute = DialogRoute<T>(
context: context,
builder: (context) {
final theme = Theme.of(context);
final surfaceOpacity = theme.surfaceOpacity;
var child = DialogOverlayContent(
route: ModalRoute.of(context) as DialogRoute<T>,
child: Builder(builder: (context) {
return builder(context);
}),
);
if (overlayBarrier != null) {
return MultiModel(
data: const [
Model(#shadcn_flutter_dialog_overlay, true),
],
child: ModalBackdrop(
modal: modal,
surfaceClip: ModalBackdrop.shouldClipSurface(surfaceOpacity),
borderRadius: overlayBarrier.borderRadius,
padding: overlayBarrier.padding,
barrierColor: overlayBarrier.barrierColor ??
const Color.fromRGBO(0, 0, 0, 0.8),
child: child,
),
);
}
return MultiModel(
data: const [
Model(#shadcn_flutter_dialog_overlay, true),
],
child: child,
);
},
themes: themes,
barrierDismissible: barrierDismissable,
barrierColor: overlayBarrier == null
? const Color.fromRGBO(0, 0, 0, 0.8)
: Colors.transparent,
barrierLabel: 'Dismiss',
useSafeArea: true,
data: data,
traversalEdgeBehavior: TraversalEdgeBehavior.closedLoop,
transitionBuilder: (context, animation, secondaryAnimation, child) {
return buildShadcnDialogTransitions(
context,
BorderRadius.zero,
Alignment.center,
animation,
secondaryAnimation,
false,
child,
);
},
alignment: Alignment.center,
);
navigatorState.push(
dialogRoute,
);
return DialogOverlayCompleter(dialogRoute);
}