show<T> static method
Future<T?>
show<T>({
- required BuildContext context,
- required WidgetBuilder builder,
- double halfSize = 0.45,
- double? fullSize,
- GlassSheetState initialState = GlassSheetState.half,
- double fillThreshold = 0.60,
- LiquidGlassSettings? settings,
- Color? expandedColor,
- ValueChanged<
GlassSheetState> ? onStateChanged, - GlassSheetMode mode = GlassSheetMode.dismissible,
- double peekSize = 90.0,
- GlassQuality? quality,
- bool platformViewBackdrop = false,
- Color barrierColor = GlassDefaults.barrierColor,
- bool isDismissible = true,
- double interactionScale = 1.01,
- bool enableInteractionGlow = true,
- bool enableSaturationGlow = true,
- LiquidGlassSettings? peekSettings,
- LiquidGlassSettings? halfSettings,
- LiquidGlassSettings? fullSettings,
- double stretch = 0.5,
- GlassModalSheetController? controller,
- GlassFillTransition fillTransition = GlassFillTransition.instant,
- bool showDragIndicator = true,
- Color? dragIndicatorColor,
- double dragIndicatorWidth = 36,
- double? topBorderRadius = 56,
- double? bottomBorderRadius,
- double? fullTopBorderRadius = 46,
- double? fullBottomBorderRadius,
- double horizontalMargin = 8.0,
- double bottomMargin = 8.0,
- double resistance = 0.08,
- double snapThreshold = 0.4,
- double velocityThreshold = 700.0,
- Color? glowColor,
- double glowRadius = 1.5,
- bool suppressInteractionOnChildren = false,
- EdgeInsetsGeometry? padding,
- bool enableTopFade = false,
- double topFadeHeight = 40.0,
- bool maintainContentGlass = true,
- LiquidGlassSettings? fullStateContentSettings,
- Set<
GlassSheetDetent> detents = const {GlassSheetDetent.medium, GlassSheetDetent.large}, - bool dismissible = true,
- bool? enablePeek,
- double? peekHorizontalMargin,
- double? peekBottomMargin,
- double? peekWidth,
- double? peekTopBorderRadius,
- double? peekBottomRadius,
Shows a high-fidelity glass modal sheet.
Implementation
static Future<T?> show<T>({
required BuildContext context,
required WidgetBuilder builder,
double halfSize = 0.45,
double? fullSize,
GlassSheetState initialState = GlassSheetState.half,
double fillThreshold = 0.60,
LiquidGlassSettings? settings,
Color? expandedColor,
ValueChanged<GlassSheetState>? onStateChanged,
GlassSheetMode mode = GlassSheetMode.dismissible,
double peekSize = 90.0,
GlassQuality? quality,
bool platformViewBackdrop = false,
Color barrierColor = GlassDefaults.barrierColor,
bool isDismissible = true,
bool useRootNavigator = false,
double interactionScale = 1.01,
bool enableInteractionGlow = true,
bool enableSaturationGlow = true,
LiquidGlassSettings? peekSettings,
LiquidGlassSettings? halfSettings,
LiquidGlassSettings? fullSettings,
double stretch = 0.5,
GlassModalSheetController? controller,
GlassFillTransition fillTransition = GlassFillTransition.instant,
bool showDragIndicator = true,
Color? dragIndicatorColor,
double dragIndicatorWidth = 36,
double? topBorderRadius = 56,
double? bottomBorderRadius,
double? fullTopBorderRadius = 46,
double? fullBottomBorderRadius,
double horizontalMargin = 8.0,
double bottomMargin = 8.0,
double resistance = 0.08,
double snapThreshold = 0.4,
double velocityThreshold = 700.0,
Color? glowColor,
double glowRadius = 1.5,
bool suppressInteractionOnChildren = false,
EdgeInsetsGeometry? padding,
bool enableTopFade = false,
double topFadeHeight = 40.0,
bool maintainContentGlass = true,
LiquidGlassSettings? fullStateContentSettings,
Set<GlassSheetDetent> detents = const {
GlassSheetDetent.medium,
GlassSheetDetent.large
},
bool dismissible = true,
bool? enablePeek,
double? peekHorizontalMargin,
double? peekBottomMargin,
double? peekWidth,
double? peekTopBorderRadius,
double? peekBottomRadius,
}) {
assert(
detents.isNotEmpty,
'GlassModalSheet.show() needs at least one detent — add medium '
'and/or large (small alone is a floor, not a resting height).');
assert(() {
if (mode == GlassSheetMode.persistent &&
barrierColor == const Color(0x00000000)) {
debugPrint(
'[GlassModalSheet] WARNING: show() with persistent mode and '
'transparent barrier does NOT provide true hit-through interaction. '
'Use GlassModalSheetScaffold directly for maps-style hit-through UI.',
);
}
return true;
}());
// Fall back to an offered detent if the caller asked to open on one
// that isn't in the set (the assert guarantees the set is non-empty).
GlassSheetState resolvedInitialState = initialState;
if (initialState == GlassSheetState.half &&
!detents.contains(GlassSheetDetent.medium)) {
resolvedInitialState = GlassSheetState.full;
} else if (initialState == GlassSheetState.full &&
!detents.contains(GlassSheetDetent.large)) {
resolvedInitialState = GlassSheetState.half;
}
final effectiveController = controller ?? GlassModalSheetController();
bool isClosing = false;
return showGeneralDialog<T>(
context: context,
barrierDismissible: isDismissible,
barrierLabel: 'Dismiss',
barrierColor: barrierColor,
useRootNavigator: useRootNavigator,
transitionDuration: const Duration(milliseconds: 500),
transitionBuilder: (context, animation, secondaryAnimation, child) {
return SlideTransition(
position: Tween<Offset>(begin: const Offset(0, 1), end: Offset.zero)
.animate(
CurvedAnimation(parent: animation, curve: Curves.easeOutQuart),
),
child: child,
);
},
pageBuilder: (context, animation, secondaryAnimation) {
return GlassModalSheetScaffold(
controller: effectiveController,
halfSize: halfSize,
fullSize: fullSize,
initialState: resolvedInitialState,
fillThreshold: fillThreshold,
settings: settings,
expandedColor: expandedColor,
mode: mode,
peekSize: peekSize,
quality: quality,
platformViewBackdrop: platformViewBackdrop,
interactionScale: interactionScale,
enableInteractionGlow: enableInteractionGlow,
enableSaturationGlow: enableSaturationGlow,
peekSettings: peekSettings,
halfSettings: halfSettings,
fullSettings: fullSettings,
stretch: stretch,
fillTransition: fillTransition,
showDragIndicator: showDragIndicator,
dragIndicatorColor: dragIndicatorColor,
dragIndicatorWidth: dragIndicatorWidth,
topBorderRadius: topBorderRadius,
bottomBorderRadius: bottomBorderRadius,
fullTopBorderRadius: fullTopBorderRadius,
fullBottomBorderRadius: fullBottomBorderRadius,
horizontalMargin: horizontalMargin,
bottomMargin: bottomMargin,
resistance: resistance,
snapThreshold: snapThreshold,
velocityThreshold: velocityThreshold,
glowColor: glowColor,
glowRadius: glowRadius,
suppressInteractionOnChildren: suppressInteractionOnChildren,
padding: padding,
enableTopFade: enableTopFade,
topFadeHeight: topFadeHeight,
maintainContentGlass: maintainContentGlass,
fullStateContentSettings: fullStateContentSettings,
detents: detents,
dismissible: dismissible,
enablePeek: enablePeek,
peekHorizontalMargin: peekHorizontalMargin,
peekBottomMargin: peekBottomMargin,
peekWidth: peekWidth,
peekTopBorderRadius: peekTopBorderRadius,
peekBottomRadius: peekBottomRadius,
onStateChanged: (state) {
onStateChanged?.call(state);
if (state == GlassSheetState.hidden && !isClosing) {
isClosing = true;
Navigator.of(context).pop();
}
},
body: const SizedBox.shrink(),
sheet: builder(context),
);
},
);
}