liquidGlass method
Widget
liquidGlass({
- CNGlassEffect effect = CNGlassEffect.regular,
- CNGlassEffectShape shape = CNGlassEffectShape.capsule,
- double? cornerRadius,
- Color? tint,
- bool interactive = false,
Applies a Liquid Glass effect to this widget.
On iOS 26+ and macOS 26+, this wraps the widget in a native container that applies the glass effect. On older versions or other platforms, the widget is returned unchanged.
The effect determines the glass variant (regular or prominent).
The shape determines the shape of the glass effect (capsule, rect, or circle).
The cornerRadius is only used when shape is CNGlassEffectShape.rect.
The tint applies a color tint to the glass effect.
The interactive makes the glass effect respond to touch/pointer interactions.
Implementation
Widget liquidGlass({
CNGlassEffect effect = CNGlassEffect.regular,
CNGlassEffectShape shape = CNGlassEffectShape.capsule,
double? cornerRadius,
Color? tint,
bool interactive = false,
}) {
// Only apply glass effect on iOS 26+ or macOS 26+
if (!PlatformVersion.supportsLiquidGlass) {
return this;
}
return LiquidGlassContainer(
config: LiquidGlassConfig(
effect: effect,
shape: shape,
cornerRadius: cornerRadius,
tint: tint,
interactive: interactive,
),
child: this,
);
}