The lens and its style
One widget, one style object: shape, appearance, refraction.
LiquidGlassLens({
LiquidGlassStyle style = const LiquidGlassStyle(),
bool visibility = true,
LiquidGlassTouch? touch,
bool? useImpellerBackdrop,
Widget? child,
})Size comes from layout, never from the lens. The child is clipped to the glass shape. visibility: false switches the glass off instantly — no backdrop cost, no child — so it is the cheap way to hide a lens you will show again.
LiquidGlassStyle#
Everything about how a lens looks lives in one object, so a look travels as a single value. copyWith(...) and merge(other) are there for theme and override patterns.
LiquidGlassStyle({
LiquidGlassShape? shape, // null → continuous rounded rect
LiquidGlassAppearance appearance = const LiquidGlassAppearance(),
LiquidGlassRefraction refraction = const LiquidGlassRefraction(),
LiquidGlassAdaptivity? adaptivity,
})Shape#
| Constructor | Corner curve |
|---|---|
LiquidGlassShape.roundedRectangle(...) | Plain circular corners. The cheapest to clip. |
LiquidGlassShape.squircle(...) | Lⁿ squircle — iOS-style continuous curvature. |
LiquidGlassShape.continuousRoundedRectangle(...) | Apple capsule-style continuous corners. The default; collapses to a clean capsule at full radius. |
All three share cornerRadius, borderWidth, borderColor, lightColor, lightIntensity, lightDirection, borderType and clipQuality.
Appearance#
| Property | Default | What it does |
|---|---|---|
color | transparent | Base tint. Usually a low-alpha white or black. |
blur | LiquidGlassBlur() | Blur applied to what shows through the glass. |
saturation | 1.0 | 1.0 unchanged, 0.0 grayscale, above 1 more vivid. |
enableInnerRadiusTransparent | false | Makes the inner, undistorted region fully transparent. |
Refraction#
| Property | Default | What it does |
|---|---|---|
distortion | 0.1 | How hard the edge band bends content, 0.0–1.0. |
distortionWidth | 30 | Thickness of that band around the perimeter, in px. |
magnification | 1.0 | Zoom of what is seen through the glass. 1.0 is none. |
chromaticAberration | 0.003 | Colour-channel separation at the rim. 0.0 disables it. |
refractionMode | shapeRefraction | shapeRefraction follows the outline; radialRefraction bends in a circular pattern. |
refractionType | null | Swap the model itself — e.g. OpticalRefraction(refraction:, refractionWidth:, depth:) for a thickness-based lens. |
Borders#
The rim is part of the shape, set through borderType. There are two models and they are genuinely different ideas, not two presets.
| Mode | What it is |
|---|---|
OpticalBorder | Default. An SDF rim light that falls out of the glass shape: background-tinted highlights, dual-sided speculars, a height profile. The rim colour adapts to whatever is behind the lens. |
ClassicBorder | Deprecated. Light and shadow sweep the outline by the angle between surface normal and light direction. Stylized, and you control the colours directly — a rim that is drawn rather than derived. Use OpticalBorder. |
// Optical: borderSaturation, ambientIntensity, borderSolidity
shape: LiquidGlassShape.squircle(
cornerRadius: 36,
borderType: OpticalBorder(
borderSaturation: 1.5,
ambientIntensity: 1.0,
borderSolidity: 0.0,
),
)
// borderWidth, lightIntensity, lightColor and lightDirection live on the
// shape itself, so they apply whichever border type is in use.
shape: LiquidGlassShape.squircle(
cornerRadius: 36,
borderWidth: 1.4,
lightIntensity: 1.0,
lightColor: Color(0xB2FFFFFF),
)Every parameter#
The tables above are the ones worth learning. The complete list — every field, every default, straight from the source — is generated on the lens API page.
Comments
Comments are GitHub Discussions — reply from either place.