SpringThemeData class final
One theme of the app as the spring.flutter.theme.* properties
describe it: colors, typography, shapes, elevations, density, motion,
spacing, component adjustments and the app's own tokens.
A theme's values come from the shared part of the properties, then the
theme it extends, then its own. They are read and checked once, when
the theme is made. The class knows no design library: the palette
(colorScheme), the text styles (textStyle) and the scales are the
same in an app without one. The Material starter makes Material's
ThemeData of it (toMaterial()), the Cupertino starter a
CupertinoThemeData (toCupertino()). The app's own widgets read the
theme shown with SpringTheme.of(context): space, textStyle,
tokenColor and the like. Only what the properties set differs from
Flutter's defaults: a theme without properties has the colors and text
styles of Flutter's own Material 3 theme.
Apps do not create it: SpringThemes makes one per theme.
// A banner sized and colored by the brand's tokens.
final theme = SpringTheme.of(context);
Container(
height: theme.tokenNumber('brand.hero-height'),
color: theme.tokenColor('brand.accent'),
padding: EdgeInsets.all(theme.space('m')),
child: Text('NEON Books', style: theme.textStyle('headlineMedium')),
);
Constructors
- SpringThemeData.of(ThemeConfig config, String name)
-
Reads theme
nameofconfigand checks every value, components included. Throws a ThemePropertyException naming the property when a value or key is invalid, or aStateErrorfor anextendscycle or an unknown parent.factory
Properties
-
animations
→ Map<
String, AnimationSpec> -
The animations of
animations.*by canonical name (borderspin).final - appColor → Color
-
The color the OS uses for the app (in the task switcher): the
palette's primary color.
no setter
- background ↔ ThemeBackgroundData?
-
The
backgroundof the theme (a color, an image, an overlay, an animation, per-screen overrides);nullwhen the theme has none.latefinal - brightness → Brightness
-
Whether the theme is light or dark:
darkfor thedarktheme and for themes that say so or extend a dark one, elselight.final - code ↔ SpringTextSpec
-
The style of monospaced text, which has no Material role:
monospaceat size 14 unlesstypography.codesays otherwise. Widgets get it withSpringTheme.of(context).textStyle('code').latefinal -
colors
→ Map<
String, Color> -
The color roles set explicitly under
colors.*, by canonical role name; they replace those of the seed's palette.final - colorScheme → SpringColorScheme
-
The full palette: Flutter's baseline, or the one the app's design
makes from the seed color (Material 3's algorithm), with the roles of
colors over it.
no setter
- contentChange ↔ ContentChangeSpec
-
How a part of a screen shows other content in its place
(
ContentChange), frommotion.content-change; none when it is not written.latefinal - contrast → double?
-
The palette's contrast, from -1 to 1;
nullfor 0.final -
curves
→ Map<
String, Curve> -
The motion curves the properties set (
motion.curves.standard), by canonical name.final - designs → ThemeDesigns
-
The designs the theme was read with.
final
-
durations
→ Map<
String, Duration> -
The motion durations the properties set (
motion.durations.medium), by canonical name.final -
elevations
→ Map<
String, double> -
The elevation levels the properties set; they replace those of
m3Elevations.
final
-
fontFamilies
→ Set<
String> -
Every font family the theme names: the main one, the fallbacks, and
those of the text styles and
code. At startup the starter logs a warning for each one it finds neither among the font assets nor underflutter: fonts:.no setter - fontFamily ↔ String?
-
The font family of all text;
nullfor the platform's.latefinal -
fontFamilyFallback
↔ List<
String> ? -
The font families used for glyphs the main family lacks (for example
Japanese text);
nullwhen not set.latefinal - frameMeter ↔ FrameMeterTheme
-
How the frame meter looks (
frame-meter), shown withspring.flutter.frame-meter.enabled.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
images
→ Iterable<
ThemeImage> -
Every image the theme names: the background's, the screens' and the
image tokens'; the starter loads those from the network.
no setter
- isPlatformPageTransition → bool
-
Whether
motion.page-transitionisplatformor not set: the design of the app chooses, per platform.no setter -
loaders
→ Map<
String, ThemeLoaderSpec> -
The loaders of
loaders.*by canonical name (neondoors).final - motionEnabled ↔ bool
-
motion.enabled(trueby default):falsemakes every motion of the app instant, as the device's "reduce motion" does: page transitions, text and content changes, the scroll to the top, the theme's animations and Flutter's own.latefinal - name → String
-
The theme's name as declared (
light,dark,ocean).final - overscroll ↔ OverscrollEffect
-
What a scrollable shows when pulled past its end, from
motion.overscroll: the app type's own (platform, the default: Material's stretch on Android) or nothing (none).latefinal - pageTransition ↔ PageTransitionsBuilder?
-
The page transition used on every platform; when not set, or for
platform, the one that leaves the choice to the app's design (isPlatformPageTransition), as Flutter does.latefinal - pageTransitions ↔ PageTransitionSpec
-
motion.page-transition: the kind, duration and curve of a router's page transitions (the platform's when not set). The navigation starter reads it; pageTransition is the same for Material's page routes.latefinal - properties → ThemeProperties
-
The theme's properties as written, relative to the theme and with
every reference resolved: what a design reads its own part from
(
components.*,cupertino.*).no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schemeVariant → String?
-
How the palette is made from the seed, as the design that makes it
names the variant (
tonalSpot,vibrant);nullfor the design's default (Material 3'stonalSpot).final - scrollToTop ↔ AnimationSpec?
-
How a screen goes back to its top when it shows another page
(
RouteContentView), frommotion.scroll-to-top: an animation, ornull(none) to jump. defaultScrollToTop when not written.latefinal - seedColor → Color?
-
The color the palette is made from;
nullwhen not set, which means Flutter's baseline palette (or its default seed when schemeVariant or contrast is set).final -
shapes
→ Map<
String, double> -
The corner radii the properties set, by canonical token name; they
replace those of m3ShapeScale.
final
-
spacing
→ Map<
String, double> -
The spacing values the properties set; they replace or extend
defaultSpacing.
final
- splash ↔ ThemeSplashData?
-
The
splashmap of the theme (what shows while the application starts);nullwhen the theme has none. (A plainsplash: rippleis the ink splash of taps,splashFactory.)latefinal -
styles
→ Map<
String, StateStyle> -
The styles of the app's own widgets,
styles.*, by canonical name (neonchip).final - textChange ↔ TextChangeSpec
-
What a ThemeText does when its text changes (another language),
from
motion.text-change; none when it is not written.latefinal -
textStyles
→ Map<
String, SpringTextSpec> -
The text styles the properties set, by canonical
TextThemename, with thedefaultsand group (display,title, ...) values merged in.final -
tokens
→ Map<
String, String> -
The app's own values under
tokens.*, as text by full path in canonical form (brand.accent,neon.modal.border.width); the items of a list have their index as the last segment (neon.modal.border.colors.0). Read them with token, tokenColor, tokenNumber, tokenDuration and the list reads.final -
unreadDesignProperties
↔ Map<
String, String> -
The theme properties of a design starter the application does not
have (
components,cupertino), with that starter: the theme has them for apps of that design, this one does not show them, and they are not checked.SpringThemeslogs them once.latefinal - wheelScroll ↔ WheelScrollSpec
-
How a mouse wheel scrolls, from
motion.wheel-scroll: Flutter's own step at once (none, the default), or eased and scaled.latefinal - widgetsTextStyle → TextStyle
-
The default text style of a
WidgetsApp: body medium in the theme's font and on-surface color.no setter
Methods
-
curve(
String name) → Curve -
The motion curve
name(standard,emphasized), as the properties set it; otherwise Material's standard easing. -
elevation(
String level) → double -
The elevation of level
level(level2). Throws anArgumentErrorfor an unknown level. -
localizedTextStyle(
String style, TextScript script) → TextStyle -
textStyle with the size, weight, line height and letter spacing the
Material 3 type scale has for
scriptwhere the properties set none: whatTheme.of(context).textThemegives in aMaterialApp.codehas no place in the scale and is as textStyle gives it. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
role(
String name) → Color? -
The color of palette role
name(surface-container,onPrimary);nullfor an unknown role. -
shape(
String token) → double -
The corner radius of shape token
token(medium,extra-large), as the properties set it or Material 3's;double.infinityforfull. Throws anArgumentErrorfor an unknown token. -
space(
String size) → double -
The spacing
sizein logical pixels:xs,s,m,l,xl, or a name the properties added. Throws anArgumentErrorfor an unknown name. -
syntaxOf(
String? language) → CodeSyntax? -
The language of
syntax.<name>thatlanguage(a fenced block's language:dart,yml) names, by name or alias;nullwhen the theme has none, and the block is plain text. -
textStyle(
String style) → TextStyle -
A finished text style of the theme: one of the 15 by name
(
titleLarge,title-large) orcode, with what the properties set over the platform's font and the palette's on-surface color. It has the size the properties give it and no other: localizedTextStyle adds the size of the type scale. Throws anArgumentErrorfor another name. -
token(
String key) → String? -
The app's token
keyas written in the properties;nullwhen it is not set. -
tokenColor(
String key) → Color? -
The app's token
key(brand.accent) read as a color;nullwhen it is not set or is no color. -
tokenColors(
String key) → List< Color> ? -
The list token
keyread as colors, each an item of a YAML list (a color or a color object) or of one comma-separated value;nullwhen it is not set or an item is no color. -
tokenDuration(
String key) → Duration? -
The app's token
key(neon.modal.open) read as a duration;nullwhen it is not set or is no duration. -
tokenImage(
String path) → ThemeImage? -
The image token
tokens.<path>(a token that is a map withsource);nullwhen there is none. -
tokenNumber(
String key) → double? -
The app's token
key(brand.hero-height) read as a number;nullwhen it is not set or is no number. -
tokenNumbers(
String key) → List< double> ? -
The list token
keyread as numbers;nullwhen it is not set or an item is no number. -
tokenTexts(
String key) → List< String> ? -
The items of the list token
key, as text: a YAML list, or one comma-separated value;nullwhen it is not set. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
defaultDurations
→ const Map<
String, Duration> -
The durations
short,mediumandlonghave when the properties do not set them. Read a motion duration withThemeKeyReader.motionDuration, which fails for an unknown name and follows the reduce-motion setting. - defaultScrollToTop → const AnimationSpec
- 400ms, ease-out-cubic.
-
themeProperties
→ const List<
String> -
The top-level properties a theme may have, whatever its design; a
design adds its own (
ThemeDesign.themeProperties:components,visual-density,cupertino). Any other key fails the start like a wrong value, so a misspelling is not silently ignored.