Liquid Glass Easy

Motion

The moving-glass model under the thumb and the pill, on its own.

LiquidGlassMotionPill deforms from how its centre moves, not from where it is. Throw it across and the pill stretches along the travel and pinches across it, then recoils past rest and settles. Hold it still at any position and the pill is exactly its declared size again.

This is the same model inside the slider's thumb and the tab bar's glass pill, and all three take the same tuning value — a LiquidGlassLensMotionSpec.

Two things happen at once#

The morph. Grab it and the pill spring-grows from restSize to activeSize, with the solid cover fading out as the glass arrives; let go and it contracts on a softer spring. The glass is a state change, not decoration that was always there.

The deformation. While it is lifted, the centre is sampled every frame and the averaged acceleration scales the two axes oppositely. That part is motion.

Dart
LiquidGlassMotionPill(
  center: Offset(edge + travel * fraction, box.height / 2),
  active: dragging,       // lifted: expanded, and tracking itself
  restSize: const Size(76, 44),
  activeSize: const Size(112, 62),
  motion: const LiquidGlassLensMotionSpec(),
  cover: myRestPill,      // fades out as the glass comes up
)
ParameterDefaultWhat it does
centerThe pill’s centre, in local coordinates. Drive it however the host moves — a drag, a glide spring, anything.
activeLifted or not. Flip it on grab and off when it should contract.
restSize / activeSizeThe two sizes it morphs between.
covernullDrawn over the glass at rest and faded out as the morph expands — the slider passes its solid white pill here. Clipped to the pill’s own outline, so pass a plain fill.
stylenullGlass look; null keeps the tuned default.
motionLiquidGlassLensMotionSpec()The tuning, below.
shadownullContact shadow. Normally left null — it travels with the rest of the look, in style.appearance.shadow.

LiquidGlassLensMotionSpec#

The shared tuning. The slider takes one as motion:, and so does the tab bar’s pillStyle.motion.

FieldDefaultWhat it does
sampleWindow0.3Seconds of recent motion averaged to read the force. Bigger is calmer, smaller is twitchier.
sensitivity0.00007Gain from acceleration to scale deviation — how strongly a given force deforms the body.
maxDeformation0.3The ceiling on how far the two scales may stray from 1. 0 turns the deformation off and leaves the plain morph.
responseTime0.18Seconds to ease toward the acceleration’s answer instead of snapping to it. 0 is the frame-locked response.

Comments

Comments are GitHub Discussions — reply from either place.