ThemeTokens class final
A project's theme as published: what the runtime draws itself (dialogs,
toasts, the loading and error screens), what layouts read at run time
(${theme.primary}, ${theme.colors.brand}, ${theme.text.title.fontSize},
${theme.isDark}) and what an app can read to match its own widgets to a
layout. Every token is optional.
dark holds the colors to use in dark mode where they differ: the
runtime reads forBrightness (dark: true), so a binding to
${theme.surface} shows the dark surface on a device in dark mode.
Older runtimes ignore colors, textStyles and dark.
- Annotations
-
- @immutable
Constructors
-
ThemeTokens({Color? primary, Color? onPrimary, Color? surface, Color? onSurface, Color? error, Color? success, Color? warning, String? fontFamily, String? titleFontFamily, double? radius, double? buttonRadius, Map<
String, Color> colors = const {}, Map<String, TextStyle> textStyles = const {}, ThemeTokens? dark}) -
const
Properties
-
Corner radius of buttons.
final
-
colors
→ Map<
String, Color> -
Every named color of the project by key (themeKey of its name:
"Brand Blue" is
brandBlue), read as${theme.colors.brandBlue}.final - dark → ThemeTokens?
-
The colors for dark mode: the tokens and colors that differ from the
light ones (its other fields are not used).
final
- error → Color?
-
Destructive buttons and error toasts.
final
- fontFamily → String?
-
Font family of body text and buttons.
final
- hasDark → bool
-
Whether dark gives any color.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
Whether no token is set.
no setter
- onPrimary → Color?
-
Text on primary.
final
- onSurface → Color?
-
Text on surface.
final
- primary → Color?
-
Primary buttons and info toasts.
final
- radius → double?
-
Corner radius of dialogs.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- success → Color?
-
Success toasts.
final
- surface → Color?
-
Dialog backgrounds.
final
-
textStyles
→ Map<
String, TextStyle> -
Every named text style by key, read as
${theme.text.title.fontSize}.final - titleFontFamily → String?
-
Font family of titles.
final
- warning → Color?
-
Warning toasts.
final
Methods
-
forBrightness(
{required bool dark}) → ThemeTokens -
These tokens for a light or
darkscreen: in dark mode each colordarkgives over the light one. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Json -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
fromJson(
Object? json) → ThemeTokens -
themeKey(
String name) → String -
The key a style named
namehas in colors and textStyles: its words in camel case ("On Primary" isonPrimary, "Title / Large" istitleLarge).
Constants
- none → const ThemeTokens