render/theme_resolver library
ThemeSpec → CalcThemeData: colours, key renderer, background, fonts
and motion springs from the integer tokens (docs/m3-theme-engine-design.md
"Layers": theme_resolver.dart).
The M2 plain theme is a ThemeSpec too (plainThemeSpec, family
plain); resolving it returns the exact PlainTheme data, so nothing
regresses.
Classes
- ThemeResolver
-
Resolves ThemeSpecs, memoising the last few so the same spec always
yields the identical CalcThemeData (cheap
==, no rebuild churn).
Properties
-
displayFaceRegistry
→ Map<
ThemeFamily, DisplayFaceFactory> -
Family → display face (the display-style hook, docs/m4-design.md §B).
Families without an entry draw the display with their font
(
CalcThemeData.displayFace == null).final -
keyFaceRegistry
→ Map<
ThemeFamily, KeyFaceFactory> -
Family → key renderer (design doc: each new family is one generator
definition plus one entry here). Families without an entry are drawn
by genericKeyFaceFor.
final
-
renderedDisplayFaceRegistry
→ Map<
ThemeFamily, RenderedDisplayFaceFactory> -
Families whose display faces take the device GlassRendering.
final
-
renderedKeyFaceRegistry
→ Map<
ThemeFamily, RenderedKeyFaceFactory> -
Families whose key renderers take the device GlassRendering; the
resolver memoises them per rendering. Everyone else is resolved with
GlassRendering.standard.
final
Functions
-
darkenArgb(
int argb, double amount) → int -
argbwith its OKLCH lightness lowered byamount(0–1), gamut mapped, alpha kept. -
displayEntryFor(
MotionSpec motion) → DisplayEntry -
The display glyph entry for
motion(motion brief §2.3). -
displayFaceFor(
ThemeSpec spec) → DisplayFace? -
The display face for
spec, chosen by family. -
genericKeyFaceFor(
ThemeSpec spec) → M3eKeyFace - The generic fallback for families without a renderer of their own: flat faces in the spec's shapes (no family-specific artwork).
-
keyFaceFor(
ThemeSpec spec) → KeyFaceRenderer -
The key renderer for
spec: chosen by family only, never by style fields. -
keyGroupOf(
KeyRole role) → KeyGroup -
The key colour group of
role(digit/decimal/sign → digit; operator; equals; everything else → function). -
lcdDisplayFaceFor(
ThemeSpec spec) → LcdDisplayFace? -
Retro's 7-segment panel for
spec(only for 7-segment specs:TypeSpec.lcd): panel = surface, ghost segments =lcdGhost, a VFD when the panel is darker than its segments; the bezel is the body a step darker (desk) or lighter (pocket). -
m3eFaceFor(
ThemeSpec spec) → M3eKeyFace - M3 Expressive renderer: rest shape → pressed rounded rect at the motion token's corner (30 % of the short side by default).
-
neoBrutalDisplayFaceFor(
ThemeSpec spec) → NeoBrutalDisplayFace -
Neo-brutalism's outlined display card for
spec: panel = surface, ink = the hard shadow colour, the heavy wide display cut from the type. -
neoBrutalFaceFor(
ThemeSpec spec) → NeoBrutalKeyFace -
Neo-brutalism keys for
spec: shadow offset = the press depth (seeded 3–5 dp), outline width from the key style, ink = the hard shadow colour (outlines come from each group'sKeyColors.edge). -
neoPopFaceFor(
ThemeSpec spec) → NeoPopKeyFace -
NeoPOP renderer for
spec: depth from the motion token (seeded 3–5 dp), side tone = palette edge, bottom tone = the edge darkened by half ofedgeShadePermillein OKLCH lightness. -
operatorGeometry(
KeyShapeSpec shape) → KeyGeometry? -
The resting KeyGeometry of operator/
=keys, or null when they use restGeometry. -
plainThemeSpec(
Brightness brightness) → ThemeSpec -
The M2 plain theme as a ThemeSpec (family
plain, id 0). Resolving it returns exactlyPlainTheme.of(brightness). -
restGeometry(
KeyShapeSpec shape) → KeyGeometry -
The resting KeyGeometry of digit/function keys in
shape. -
retroFaceFor(
ThemeSpec spec) → RetroKeyFace -
Retro keycaps for
spec: travel from the motion token (seeded 2–3 dp), skirts = palette edges, bevel and contact shadow from the palette's highlight / shadow. -
springFromToken(
SpringToken token) → SpringDescription - A mass-1 spring from an integer token (motion brief §2.6).
Typedefs
- DisplayFaceFactory = DisplayFace? Function(ThemeSpec spec)
- Builds the display face for a spec of one family.
- KeyFaceFactory = KeyFaceRenderer Function(ThemeSpec spec)
- Builds the key renderer for a spec of one family.
- RenderedDisplayFaceFactory = DisplayFace? Function(ThemeSpec spec, {GlassRendering rendering})
- A family display face that honours the device's GlassRendering.
- RenderedKeyFaceFactory = KeyFaceRenderer Function(ThemeSpec spec, {GlassRendering rendering})
- A family key renderer that honours the device's GlassRendering (Reduce Transparency, the lite effects tier).