GlassThemeData class Foundations

The tokens a screen's glass reads.

The material (finish), the rung of the ladder (tier), what is behind the glass (backdrop, richBackdrop), the platform's increase-contrast switch (highContrast), a floor for the labels (minLabelContrast), and motion (ripple, dropMotion, press). A GlassHost installs one built from its own arguments; a GlassTheme below it changes them for a subtree.

What the glass draws from these — the finish after any dim, the label colour and the outline — is legibility, in one place, so the surface, the group and the components cannot disagree.

// The screen's theme, with a label floor of WCAG AA for one subtree.
final GlassThemeData data = GlassTheme.of(context).copyWith(
  minLabelContrast: kTextContrastAA,
);
final GlassLegibility drawn = data.legibility();
final Color labelColour = drawn.label;

See also:

Annotations

Constructors

GlassThemeData({GlassFinish finish = GlassFinish.regularDark, GlassTierChoice tier = GlassTierChoice.byDefault, Color? backdrop, bool highContrast = false, bool richBackdrop = false, double? minLabelContrast, GlassRipple? ripple, GlassDropMotion dropMotion = const GlassDropMotion(), GlassPress press = const GlassPress(), GlassAdaptive? adaptive, Brightness? regularAppearance, GlassBackdropReading? reading})
Tokens with the package's defaults: the dark branch of .regular, the top rung, nothing declared about the backdrop, no ripple, and the default drop motion.
const

Properties

adaptive → GlassAdaptive?
Whether glass under this theme reads its own backdrop, and how; null for glass that goes by what is declared. Installed by GlassHost.adaptive.
final
backdrop → Color?
What is behind the glass, on average — the screen's own background colour.
final
dropMotion → GlassDropMotion
How a held drop deforms as it launches and brakes, unless a control declares its own; GlassDropMotion.none for a drop that keeps its shape. Ignored under reduced motion. See GlassDropMotion.
final
finish → GlassFinish
The material every surface wears unless it names its own.
final
hashCode → int
The hash code for this object.
no setteroverride
highContrast → bool
Whether the platform's increase-contrast switch is on.
final
minLabelContrast → double?
The least contrast a component's label must have against the glass, or null to leave the finish alone.
final
press → GlassPress
How a pressed GlassButton swells and leans toward a dragging finger, unless it declares its own; GlassPress.none for a button that keeps its box. Ignored under reduced motion. See GlassPress.
final
reading → GlassBackdropReading?
What the glass this theme was installed for read of its backdrop, or null when it read nothing.
final
regularAppearance → Brightness?
The platform appearance finish was picked in when it is .regular — nobody named it — and null when it was named.
final
richBackdrop → bool
Whether what is behind the glass is an image — a photograph, a video, a map — rather than a colour.
final
ripple → GlassRipple?
The wave every surface makes when touched, unless it declares its own; null for none, which is the platform's behaviour. See GlassRipple.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tier → GlassTierChoice
Which rung of the ladder is drawn, and why.
final

Methods

adaptedTo(GlassBackdropReading reading) → GlassThemeData
This theme as it applies over one glass whose backdrop read reading.
copyWith({GlassFinish? finish, GlassTierChoice? tier, Color? backdrop, bool? highContrast, bool? richBackdrop, double? minLabelContrast, GlassRipple? ripple, GlassDropMotion? dropMotion, GlassPress? press, GlassAdaptive? adaptive, Brightness? regularAppearance, GlassBackdropReading? reading}) → GlassThemeData
This theme with the named tokens replaced.
legibility([GlassFinish? own, bool labelled = true]) → GlassLegibility
The finish surfaces draw, and the label and outline colours they use — everything the tokens above decide, in one place, so the surface, the group and the components cannot disagree.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
withAdaptive(GlassAdaptive? adaptive) → GlassThemeData
This theme with adaptive replaced — null included, which copyWith cannot say.

Operators

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