GlassDropMotion class Foundations

How a held drop deforms as it moves: stretched along its travel while it speeds up, squashed while it slows down, round at a constant speed.

Read by GlassSwitch, GlassSlider, GlassSegmentedControl and GlassTabBar from GlassThemeData.dropMotion, unless the widget names its own. none turns it off, and so does the platform's reduced-motion switch.

A feel rather than a measurement: Apple's held drops lean into a fast slide and bulge as they stop, and what is taken here is the shape of that, not its numbers. The deformation keeps the drop's area and follows its target through a spring, so it wobbles back rather than snapping.

It costs no capture — the drop changes size inside the travel region it already moves in — and a repaint of the drop's own layer on the frames the stretch changes.

// Softer for the whole screen, and none at all on one switch.
GlassHost(
  dropMotion: const GlassDropMotion(maxStretch: 0.06),
  child: navigator!,
)

GlassSwitch(
  value: on,
  onChanged: (bool value) => setState(() => on = value),
  dropMotion: GlassDropMotion.none,
)

See also:

Annotations

Constructors

GlassDropMotion({double maxStretch = 0.12, double saturation = 10000, Duration smoothing = const Duration(milliseconds: 16), double stiffness = 900, double damping = 30})
A drop motion with the package's defaults: up to 12% of stretch, on a spring with a damping ratio of 0.5.
const

Properties

damping → double
The spring's damping, at unit mass. See stiffness.
final
hashCode → int
The hash code for this object.
no setteroverride
isNone → bool
Whether this deforms nothing.
no setter
maxStretch → double
The most the drop stretches or squashes: at 0.12 it is up to 12% longer and 1/1.12 as thick launching, and 12% shorter and 1/0.88 as thick braking. Zero is none.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
saturation → double
The acceleration along the travel, logical px/s², that takes the drop to three quarters of maxStretch (tanh(1)): the deformation saturates smoothly towards maxStretch past it. A tab bar's drop springing one tab over starts at about 27 000 px/s² and is past it in a frame or two, so — after smoothing and the spring — the defaults draw it about 7% long setting off and 5% short arriving; three tabs, 11% and 12%; a finger dragged at 1000 px/s and let stop, 9% and 8%; the switch's 22 px, 3%.
final
smoothing → Duration
The time constant of the low-pass on the velocity and on the acceleration. A second derivative of positions sampled once a frame from a finger is mostly noise without it.
final
stiffness → double
The spring the deformation follows its target with, at unit mass: what makes it wobble back rather than snap. 900 and 30 is a damping ratio of 0.5 — a little jelly, back in about half a second.
final

Methods

copyWith({double? maxStretch, double? saturation, Duration? smoothing, double? stiffness, double? damping}) → GlassDropMotion
This motion with the named fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orNoneUnderReducedMotion(BuildContext context) → GlassDropMotion
none when context asks for reduced motion; this otherwise.
reach(Size size) → Size
How far past its held size a drop of size can reach, per side, under this motion: half the stretch across, half the squash down. What a control grows its travel region by, so a deformation never leaves it.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

resolve(BuildContext context, GlassDropMotion? declared) → GlassDropMotion
The motion a control in context uses: its own declared, else the theme's — and none either way under reduced motion.

Constants

none → const GlassDropMotion
No deformation at all: the drop is the shape it is held at.