show<T> static method
Future<T?>
show<T>({
- required BuildContext context,
- required WidgetBuilder builder,
- LiquidGlassSettings? settings,
- GlassQuality? quality,
- bool showDragIndicator = true,
- Color? dragIndicatorColor,
- EdgeInsetsGeometry? padding,
- double topBorderRadius = 32.0,
- double? bottomBorderRadius,
- EdgeInsets margin = const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
- bool isScrollable = true,
- double interactionScale = 1.01,
- double stretch = 0.5,
- double resistance = 0.08,
- Axis stretchAxis = Axis.vertical,
- bool allowPositiveStretch = false,
- bool allowNegativeStretch = true,
- bool enableInteractionGlow = true,
- Color? glowColor,
- double glowRadius = 1.5,
- bool suppressInteractionOnChildren = false,
- bool isDismissible = true,
- bool enableDrag = true,
- Color? barrierColor,
- bool useSafeArea = true,
- bool enableSaturationGlow = true,
Shows a glass bottom sheet.
Returns a Future that resolves to the value (if any) passed to Navigator.pop when the sheet is dismissed.
Parameters:
context: Build context for showing the sheetbuilder: Builder function that creates the sheet contentsettings: Glass effect settings (null uses defaults)quality: Rendering quality (defaults to standard)showDragIndicator: Whether to show the drag indicator (default: true)dragIndicatorColor: Color of the drag indicatorpadding: Padding around the contenttopBorderRadius: Corner radius of the sheet (default: 54)margin: External margin for the "floating" look (default: 8x8)isScrollable: Whether the content should be scrollable (default: true)interactionScale: Visual scale feedback on touch (default: 1.01)stretch: Liquid stretch intensity (default: 0.5)resistance: Drag resistance factor (default: 0.08)stretchAxis: Axis for the liquid effect (default: vertical)allowPositiveStretch: Enable stretch in positive direction (default: false)allowNegativeStretch: Enable stretch in negative direction (default: true)enableInteractionGlow: Whether to show tactile glare on touch (default: true)glowColor: Color of the interaction glowglowRadius: Radius of the interaction glowenableSaturationGlow: Whether to pulse saturation/lighting on touch (default: true)suppressInteractionOnChildren: Enable "Smart Silence" for child interactionsisDismissible: Whether tapping outside dismisses the sheet (default: true)enableDrag: Whether the sheet can be dragged down to dismiss (default: true)barrierColor: Color of the modal barrier (defaults to black54)useRootNavigator: Whether to show the sheet in the root navigator (default: false)useSafeArea: Whether to wrap the content in a safe area (default: true)
Example:
final result = await GlassSheet.show<String>(
context: context,
builder: (context) => /* content */,
);
Implementation
static Future<T?> show<T>({
required BuildContext context,
required WidgetBuilder builder,
LiquidGlassSettings? settings,
GlassQuality? quality,
bool showDragIndicator = true,
Color? dragIndicatorColor,
EdgeInsetsGeometry? padding,
double topBorderRadius = 32.0,
double? bottomBorderRadius,
EdgeInsets margin = const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
bool isScrollable = true,
double interactionScale = 1.01,
double stretch = 0.5,
double resistance = 0.08,
Axis stretchAxis = Axis.vertical,
bool allowPositiveStretch = false,
bool allowNegativeStretch = true,
bool enableInteractionGlow = true,
Color? glowColor,
double glowRadius = 1.5,
bool suppressInteractionOnChildren = false,
bool isDismissible = true,
bool enableDrag = true,
Color? barrierColor,
bool useRootNavigator = false,
bool useSafeArea = true,
bool enableSaturationGlow = true,
}) {
return showGeneralDialog<T>(
context: context,
barrierDismissible: isDismissible,
barrierLabel: 'Dismiss',
barrierColor: barrierColor ?? GlassDefaults.barrierColor,
useRootNavigator: useRootNavigator,
transitionDuration: const Duration(milliseconds: 350),
transitionBuilder: (context, animation, secondaryAnimation, child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 1),
end: Offset.zero,
).animate(CurvedAnimation(
parent: animation,
curve: Curves.easeOutCubic,
reverseCurve: Curves.easeInCubic,
)),
child: child,
);
},
pageBuilder: (context, animation, secondaryAnimation) {
return SafeArea(
bottom: useSafeArea,
top: false,
left: false,
right: false,
child: Align(
alignment: Alignment.bottomCenter,
child: _DismissibleSheetWrapper(
enableDrag: enableDrag,
child: GlassSheet(
settings: settings,
quality: quality,
showDragIndicator: showDragIndicator,
dragIndicatorColor: dragIndicatorColor,
padding: padding,
topBorderRadius: topBorderRadius,
bottomBorderRadius: bottomBorderRadius,
margin: margin,
isScrollable: isScrollable,
interactionScale: interactionScale,
stretch: stretch,
resistance: resistance,
stretchAxis: stretchAxis,
allowPositiveStretch: allowPositiveStretch,
allowNegativeStretch: allowNegativeStretch,
enableInteractionGlow: enableInteractionGlow,
glowColor: glowColor,
glowRadius: glowRadius,
enableSaturationGlow: enableSaturationGlow,
suppressInteractionOnChildren: suppressInteractionOnChildren,
child: builder(context),
),
),
),
);
},
);
}