GlassRipple class Foundations
How a glass surface answers a touch with a wave.
The defaults are chosen by eye, not measured — there is no reference to measure against, since the platform has no such effect.
A touch launches a front from where the finger landed and another from where it left, and holds a dimple under the finger while it is down. viscosity is the one knob most applications need: 0 is water, which rings, and 1 is honey, one slow bump.
Opt-in, and not Apple's: iOS answers a touch with light and a scale and never deforms the material. It takes no capture and repaints nothing — a frame of a wave only re-records the glass's draw — and it is not drawn under the platform's reduced-motion switch, by a member of a fusing GlassGroup, or on a rung below GlassTier.full.
Declared for a whole screen on the host, or for one glass on the surface:
GlassHost(
ripple: const GlassRipple(viscosity: 0.3),
child: navigator!,
)
GlassSurface(
ripple: const GlassRipple(viscosity: 1, amplitude: 4),
child: const SizedBox.square(dimension: 120),
)
Note: the ripple is a separate shader, loaded the first time a surface asks for one. GlassHost.precache loads it up front.
See also:
- GlassHost.ripple, GlassThemeData.ripple and GlassSurface.ripple, where a ripple is declared.
- Ripple on the site.
- Annotations
Constructors
Properties
- amplitude → double
-
Peak sample displacement of a front at birth, logical px. Every term is
normalised so that this is a bound and not a scale: no fragment moves
further than the sum of the amplitudes alive.
final
- decay → double
-
Seconds for a front's amplitude to fall by e.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- light → double
-
How much a slope lit from above brightens (and one facing down darkens),
as a fraction of full scale at the steepest slope. 0 for a wave that only
refracts.
final
- press → double
-
Depth of the dimple held under the finger, as a fraction of amplitude.
0 for a ripple with no dimple and no spring-back.
final
- pressRadius → double
-
The dimple's radius, logical px.
final
- ringing → double
-
Oscillation inside a front, radians per half-width.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- speed → double
-
How fast a front travels, logical px per second.
final
- spread → double
-
px² per second the front's half-width squared grows by.
no setter
- springOmega → double
-
The dimple's spring: natural frequency, rad/s, and damping ratio.
no setter
- springZeta → double
-
The dimple spring's damping ratio: below 1 it overshoots, at 1 it settles
critically damped.
no setter
- viscosity → double
-
0 is thin — the front rings, the dimple overshoots — and 1 is honey: one
bump that broadens and settles without overshooting.
final
- width → double
-
The front's half-width at birth, logical px.
final
Methods
-
copyWith(
{double? amplitude, double? speed, double? width, double? viscosity, double? press, double? pressRadius, double? light}) → GlassRipple - This ripple with the named fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override