Liquid Glass Easy

Shape helpers

The free functions the renderers use to clip and trace a lens outline. Exported because both halves of the library need them; you will rarely call one directly.

function

liquidGlassClip#

Wraps child in the clip that matches shape's outline, honoring its LiquidGlassShape.clipQuality: a circular ClipRRect, a shader-matched squircle ClipPath, or an Apple capsule-style continuous ClipPath. Used by the renderers so the clipped blur/child silhouette agrees with the SDF the shader draws.

Signature

liquidGlassClip({ required LiquidGlassShape shape, required Widget child, Offset shapeScale = const Offset(1, 1), })
ParameterTypeDefaultDescription
shaperequiredLiquidGlassShape
childrequiredWidget
shapeScaleOffsetconst Offset(1, 1)

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

function

liquidGlassClipCornerRadius#

The corner radius used to clip a lens to its outline.

Signature

liquidGlassClipCornerRadius(LiquidGlassShape shape)
ParameterTypeDefaultDescription
shapeLiquidGlassShape

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

function

liquidGlassCornerStyle#

The shader corner-style selector (u_cornerStyle), derived from LiquidGlassShape.cornerStyle:

Signature

liquidGlassCornerStyle(LiquidGlassShape shape)
ParameterTypeDefaultDescription
shapeLiquidGlassShape

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

function

liquidGlassUsesRoundedClip#

Whether the shape uses a rounded clip for its blur-backdrop and child clips. Every LiquidGlassShape is a rounded-rectangle family shape, so this is always true — kept as a named predicate for the renderers' call sites.

Signature

liquidGlassUsesRoundedClip(LiquidGlassShape shape)
ParameterTypeDefaultDescription
shapeLiquidGlassShape

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

function

liquidGlassCornerSegments#

Tessellation density for a corner of on-screen reach — shared by both curved corner styles. A corner spans 2 × this many straight segments.

reach is the corner's actual extent — the continuous curve's r · (1 + slack), the squircle's zone — NOT its radius. A stretched corner covers more ground per step than a round one of the same radius, and keying this on r alone lets an extreme aspect ratio slip past the budget (measured: 600×24 at r 12 strayed 0.052 px).

Inverts the sagitta law for the clip's error budget (0.05 logical px), so a small pill is not tessellated to the same density as a full-screen card. Floored at 3 so even a hairline radius keeps a curve, and capped at 40.

Signature

liquidGlassCornerSegments(double reach)
ParameterTypeDefaultDescription
reachdouble

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

function

liquidGlassSquirclePath#

The continuous-curvature (squircle) outline — the SAME L^n superellipse the shader draws. zone and n are derived exactly like continuousCornerParams in liquid_glass_common.glsl, so the clip lines up with the refraction.

Signature

liquidGlassSquirclePath(Size size, double r, double smoothing, { int? seg, double renderScale = 1.0, })
ParameterTypeDefaultDescription
sizeSize
rdouble
smoothingdouble
segint?
renderScaledouble1.0

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

function

liquidGlassContinuousRoundedRectPath#

The capsule-style continuous rounded-rectangle outline: each corner is a p-norm ball whose box is stretched along whichever edge has room, with an exponent that rises with that same room. The stretch is what makes the corner read as continuous — the curve leaves the edge at r · (1 + 0.2893) with zero tangent and curvature, instead of turning in at r.

This is the Dart twin of the shader's continuousRoundedRect* SDF, so the LiquidGlassClipQuality.continuous clip lines up with the refraction.

Both the reach and the exponent ramp with each edge's slack, so a square at full radius collapses to a clean circle and a capsule keeps a circular end cap while its long flank stays smoothed.

Signature

liquidGlassContinuousRoundedRectPath(Size size, double r, { int? seg, double renderScale = 1.0, })
ParameterTypeDefaultDescription
sizeSize
rdouble
segint?
renderScaledouble1.0

Declared in lib/src/widgets/utils/liquid_glass_shape.dart

Comments

Comments are GitHub Discussions — reply from either place.