GlassContainer class

A foundational glass container widget following Apple's liquid glass design.

This is the base primitive for all container-based glass widgets. It provides a simple glass surface with configurable dimensions, padding, and shape.

Usage Modes

Grouped Mode (default)

Uses LiquidGlass.grouped and inherits settings from parent LiquidGlassLayer:

AdaptiveLiquidGlassLayer(
  settings: LiquidGlassSettings(...),
  child: Column(
    children: [
      GlassContainer(
        child: Text('Hello'),
      ),
      GlassContainer(
        child: Text('World'),
      ),
    ],
  ),
)

Standalone Mode

Creates its own layer with LiquidGlass.withOwnLayer:

GlassContainer(
  useOwnLayer: true,
  settings: LiquidGlassSettings(
    thickness: 30,
    blur: 10,
  ),
  child: Text('Standalone'),
)

Customization Examples

Custom padding and shape:

GlassContainer(
  padding: EdgeInsets.all(20),
  shape: LiquidRoundedSuperellipse(borderRadius: 16),
  child: Text('Padded content'),
)

With constraints:

GlassContainer(
  width: 200,
  height: 100,
  child: Center(child: Text('Fixed size')),
)

With clipping:

GlassContainer(
  clipBehavior: Clip.antiAlias,
  child: Image.network('...'),
)
Inheritance

Constructors

GlassContainer({Key? key, Widget? child, double? width, double? height, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, LiquidShape shape = const LiquidRoundedSuperellipse(borderRadius: 16), LiquidGlassSettings? settings, bool useOwnLayer = false, GlassQuality quality = GlassQuality.standard, Clip clipBehavior = Clip.none, AlignmentGeometry? alignment, bool allowElevation = false})
Creates a glass container.
const

Properties

alignment AlignmentGeometry?
The alignment of the child within the container.
final
allowElevation bool
Whether to allow elevation effects when in a grouped context.
final
child Widget?
The widget below this widget in the tree.
final
clipBehavior Clip
The clipping behavior for the container.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
Height of the container in logical pixels.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
margin EdgeInsetsGeometry?
Empty space to surround the glass container.
final
padding EdgeInsetsGeometry?
Empty space to inscribe inside the glass container.
final
quality GlassQuality
Rendering quality for the glass effect.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
settings LiquidGlassSettings?
Glass effect settings (only used when useOwnLayer is true).
final
shape LiquidShape
Shape of the glass container.
final
useOwnLayer bool
Whether to create its own layer or use grouped glass within an existing layer.
final
width double?
Width of the container in logical pixels.
final

Methods

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
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