Liquid Glass Easy

Switch

A switch whose handle becomes glass under your thumb.

LiquidGlassSwitch is self-contained in the same way as the slider — its own background, its own refracted track, no view and no capture anywhere near it.

Dart
LiquidGlassSwitch(
  value: wifi,
  onChanged: (v) => setState(() => wifi = v),
  activeColor: const Color(0xFF0A84FF),
  width: 64,
  height: 28,
)
ParameterDefaultWhat it does
valueOn or off.
onChangedFires on tap and on drag-release.
activeColor0xFF34C759Track colour when on.
inactiveColor0x4C787880Track colour when off.
thumbColorwhiteThe contracted rest thumb.
width / heightnullShorthands for the same two fields on layout, and they win over them. They size the track, not the thumb.
layoutLiquidGlassSwitchLayout()Track and thumb geometry. Defaults to the iOS-26 63×28 capsule; everything else is derived from it.
stylenullOverrides the handle glass.
reserveSwellRoomfalseReserves layout room for the press swell instead of letting it paint outside. Turn it on under a clipping ancestor.
pixelRatio1.0Capture resolution for the inner view.

The handle is not a picture of glass#

At rest the thumb is a solid pill and the lens beneath it contributes nothing — fully frosted, no bend, no rim. Press it and the solid dissolves as the optics come up together, so the glass arrives as a state change instead of being revealed behind a fading white. Hold one down and the track bends through it.

Comments

Comments are GitHub Discussions — reply from either place.