GlassFinish class Foundations
What the glass does to the light it lets through: how much it blurs and how much of it survives.
A finish is a blur (blurSigmaLogical), a tint laid over the blurred sample (tint), an additive outline (rim) and the bend at the edge (optics). The host's finish is what every surface under it wears; a GlassSurface or a GlassTheme can name another.
Every damage number the package carries is keyed by a finish's name.
Four finishes are calibrated against Apple's own materials:
| Finish | Blur sigma | Looks like |
|---|---|---|
| regularDark | 2.6 | .regular over dark content: dark, and barely transmitting |
| regularLight | 2.6 | .regular over light content |
| clear | 0 | .clear: no blur, a light tint, the bend in full |
| frosted | 8 | a heavy blur with a light, thin tint |
regular picks between the two branches of .regular the way Apple's
material does, and is what a host with no GlassHost.finish wears.
identity is a check rather than a look: a surface wearing it is invisible.
GlassSurface(
finish: GlassFinish.clear,
borderRadius: const BorderRadius.all(Radius.circular(28)),
child: const Padding(
padding: EdgeInsets.all(20),
child: Text('Clear glass'),
),
)
Note: a finish whose name is not one of the measured ones gets refusals from the resolution policy rather than numbers. Derive a custom finish with copyWith and keep the name of the one it is closest to.
See also:
- GlassOptics, the shape of the bend at the edge.
- GlassHost.finish and GlassThemeData.finish, where a finish is named for a screen or a subtree.
- GlassThemeData.legibility, which dims a finish for its label.
- Finishes and Legibility on the site.
- Annotations
Constructors
- GlassFinish({required String name, required double blurSigmaLogical, required Color tint, Color rim = kCalibratedRim, GlassOptics optics = const GlassOptics()})
-
A finish of its own. The
namekeys it into the measured damage tables, so a finish nobody has graded should borrow the name of its nearest one.const
Properties
- blurSigmaLogical → double
-
The blur, in logical pixels, applied to the proxy before it is sampled.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- name → String
-
Key into the measured damage tables (ProxyResolution.meanDamage,
ProxyStaleness.damageAt). A finish whose name is not among the measured ones gets refusals rather than numbers, which is the intended behaviour for a finish nobody has graded.final - optics → GlassOptics
-
How the glass bends what it samples at the edge. See GlassOptics.
final
- rim → Color
-
What the outline adds.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tint → Color
-
Laid over the refracted sample as
mix(base, rgb, a).final
Methods
-
copyWith(
{String? name, double? blurSigmaLogical, Color? tint, Color? rim, GlassOptics? optics}) → GlassFinish - This finish with the named fields replaced.
-
dimmed(
double dim) → GlassFinish -
This finish over a black dimming layer of opacity
dim, as one finish. -
dimmingFor(
double minContrast, {Color label = const Color(0xFFFFFFFF)}) → double? -
The least dimming layer under this finish that gives
labela worst-case contrast ofminContrastover any backdrop, or null when no dimming does. -
foregroundOver(
Color backdrop, {Color dark = const Color(0xFF000000), Color light = const Color(0xFFFFFFFF)}) → Color -
The label colour with more contrast against the level this finish shows
over
backdrop—darkorlight, whichever wins. -
foregroundOverAny(
{Color dark = const Color(0xFF000000), Color light = const Color(0xFFFFFFFF)}) → Color -
The label colour —
darkorlight— whose worst contrast over any backdrop is the larger. -
highContrastRim(
{Color? backdrop}) → Color - The outline under the platform's increase-contrast switch: an opaque line of the colour with the most contrast against this finish, rather than the calibrated additive white.
-
levelRange(
) → ({Color darkest, Color lightest}) - The darkest and lightest level this finish can show, over any backdrop at all — the fill over black and the fill over white.
-
materializing(
double progress) → GlassFinish -
This finish part of the way through appearing,
progressfrom 0 (not there) to 1 (this finish). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
opaqueFillOver(
Color backdrop) → Color -
The level this finish shows over a backdrop of
backdrop, as an opaque fill — what GlassTier.opaque paints. -
toString(
) → String -
A string representation of this object.
override
-
worstContrast(
Color label) → double -
The least contrast
labelcan have against this finish, over any backdrop — the number that is true on a photograph.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
contrastRatio(
Color a, Color b) → double - WCAG's contrast ratio between two opaque colours, 1.0 to 21.0.
-
lerp(
GlassFinish a, GlassFinish b, double t) → GlassFinish -
The finish part of the way from
atob,tfrom 0 to 1 — what a glass that reads its backdrop draws while it moves between the branches of.regular(GlassHost.adaptive). -
levelOf(
Color colour) → double -
The level regular switches on:
colour's Rec.709 luma over its encoded channels, in code values of 255 — the scale kRegularSwitchLight and kRegularSwitchDark were read in. -
regular(
{required Brightness appearance, Color? backdrop}) → GlassFinish -
Apple's
.regular: regularDark or regularLight, as the material would choose overbackdropinappearance.
Constants
- clear → const GlassFinish
- No blur at all: the refraction reads the proxy straight. The hardest case for every degradation.
- frosted → const GlassFinish
-
A heavy blur with a light, thin tint. Scored against Apple's materials it
is closer to
UIVisualEffectView(.systemMaterial)than to Liquid Glass; kept because it is the honest name for a heavy blur and the damage tables carry it. - identity → const GlassFinish
- Nothing at all: no blur, no tint, no outline, no displacement.
- kRegularSwitchDark → const double
- The same switch in the dark appearance: read between 220 and 224.
- kRegularSwitchLight → const double
-
Below this backdrop level
.regularis regularDark in the light appearance, and at or above it regularLight — encoded code values of a grey. - regularDark → const GlassFinish
-
The dark branch of Apple's
Glass.regular, calibrated on its two axes, blur and transmission, which are independent of each other. - regularLight → const GlassFinish
-
The light branch of
.regular: what Apple's material is over a light backdrop.