ThemeData class final

The styles of an app by what they are for, which widgets draw in: the background slots (background, surface, selection) set a background, the others a text color. Presets: dark, light, nord, catppuccinMocha, catppuccinLatte and ThemeData.terminal, the terminal's own colors.

Besides the twelve slots, the tokens the design draws with, each derived from the slots unless given: chrome, well, faint, dim, selectionIdle, hover, onPrimary, and a barrier's shade and shadeAlpha; and fill, a color filled with text that reads on it. Where the slots they mix are RGB they are mixed as the design does; where one is a palette color (as in ThemeData.terminal) a token falls back to the slot it starts from.

ThemeData.lerp blends two themes, AnimatedTheme cross-fades from one to the next.

A preset with another primary color:

final data = ThemeData.dark.copyWith(
  primary: const Style(fg: Color.rgb(0xff, 0x8c, 0x00)),
);
Annotations
  • @immutable

Constructors

ThemeData({required Brightness brightness, required Style background, required Style surface, required Style text, required Style muted, required Style primary, required Style accent, required Style border, required Style selection, required Style error, required Style warning, required Style success, required Style info, Style? chrome, Style? well, Style? faint, Style? dim, Style? selectionIdle, Style? hover, Style? onPrimary, Style? shade, double? shadeAlpha, Map<int, int> palette = const {}, PointerMode pointerMode = PointerMode.auto, Glyphs glyphs = Glyphs.unicode})
A theme of the twelve slots and brightness; each token left out is derived from the slots, and shadeAlpha, from 0 to 1 (an assert), from brightness. selection must have a background, as a Theme asserts: what is selected is painted on it, and text over it keeps it.
const
ThemeData.lerp(ThemeData a, ThemeData b, double t)
The theme t of the way from a to b, for a cross-fade: a at 0, b at 1. Each slot and token blends as a StyleTween has it (RGB colors channel by channel, others switching halfway), shadeAlpha as a number; the brightness switches halfway. The tokens are blended as they are in a and b, not derived again.
factory
ThemeData.terminal(Brightness brightness)
The terminal's own colors, so that its color scheme shows through: its default background and text color and the colors of its palette. For surface, muted, border, selection, selectionIdle and hover greys of the 256 colors, which no color scheme changes, rather than the background (a toast, a dialog would not stand out of the page), dim text, which some terminals ignore, or reverse video, which a text painted over it would not keep. A ladder from the background: on a dark terminal surface 234 (#1c1c1c), selectionIdle 235 (#262626), hover 236 (#303030), selection 237 (#3a3a3a), border 240 (#585858), muted 245 (#8a8a8a); on a light one 255 (#eeeeee), 254 (#e4e4e4), 253 (#dadada), 252 (#d0d0d0), 250 (#bcbcbc), 243 (#767676). What a terminal that told its colors is in: ThemeData.terminalOn.
const
ThemeData.terminalOf(BuildContext context)
The terminal's own colors as context has them: ThemeData.terminalOn where the terminal told its background (TerminalBrightness), else ThemeData.terminal of its brightness. context depends on them.
factory
ThemeData.terminalOn(int background, {int? foreground, Map<int, int> palette = const {}})
The terminal's own colors on a terminal that told its default background and foreground (0xRRGGBB; foreground white on a dark background and black on a light one where it did not): as ThemeData.terminal of background's brightness, its greys mixed from the two instead, so that each is a step from the background whatever it is: muted 0.6 of the way from background to foreground, dim 0.45, border 0.3, selection and faint 0.2, hover 0.13, selectionIdle 0.1, surface 0.07. A fixed grey can be the background's own color (the 237 of ThemeData.terminal on Breeze's #31363b).
factory

Properties

accent → Style
A second color for highlights, apart from primary.
final
background → Style
The app's background, under everything else.
final
border → Style
Borders of boxes, separators.
final
brightness → Brightness
Whether the theme is dark (light text on a dark background) or light.
final
chrome → Style
The app's frame around its content (a header, a sidebar, the key hints), a background: a step from background towards surface, half of it on a dark theme, 0.55 on a light one. surface where either is not RGB.
no setter
dim → Style
Text that matters least, a text color: counts, line numbers, sizes. muted 0.2 of the way to background, 3 to 1 against it in every preset; muted where either is not RGB.
no setter
error → Style
Errors and what failed.
final
faint → Style
Quiet lines, a text color: rules that only separate, dots of a stage. background 0.55 of the way to border on a dark theme, 0.6 on a light one; border where either is not RGB.
no setter
glyphs → Glyphs
The marks widgets draw (checks, cursor bars, a scrollbar's thumb and track, a gauge's line, the spinner) by what they mean: Glyphs.unicode by default, Glyphs.ascii for a terminal without the others, or a set of an app's own.
final
hashCode → int
The hash code for this object.
no setteroverride
hover → Style
What the mouse is over, a background: a row, a header, a button's chip lit. background 0.08 of the way to text; selectionIdle where either is not RGB (a grey of its own in ThemeData.terminal).
no setter
info → Style
Information, neither good nor bad.
final
muted → Style
Text that matters less: hints, placeholders, what is disabled.
final
onPrimary → Style
Text on a primary fill, a text color: a focused button. On a dark theme of RGB colors background's color, otherwise white: on the terminal's palette the blue is the terminal's own, and its black, bold, many terminals draw bright, a grey that hardly reads on it.
no setter
palette → Map<int, int>
The colors the terminal draws the entries of its palette in, RGB by index, as it told them (TerminalBrightness.palette): what fill picks the text on a palette color by, where xterm's own would mislead (the red of a themed terminal a pink). Empty for none told: xterm's. ThemeData.terminalOn gives it.
final
pointerMode → PointerMode
How far the widgets set the pointer's shape, where the terminal shows it: PointerMode.auto by default. The hand shows over what a click presses: the buttons, boxes and switches, tabs, menu titles and items, a stepper's steps, a dismiss [x], a sortable table header, the keys of a pressable KeyHintsBar, a Span.tap. Rows of a list keep the arrow: a hand over all of them would tell nothing.
final
primary → Style
The color of what is active: the focused control, buttons, links.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selection → Style
What is selected: rows of a list, text; a background, never null.
final
selectionIdle → Style
A selection whose list has not the focus, a background: selection 0.35 of the way to background, apart from both in every preset (a tint of the selection's on a surface); selection where either is not RGB (a grey of its own in ThemeData.terminal).
no setter
setsPointerShapes → bool
Whether the widgets set the pointer's shape at all.
no setter
shade → Style
What a modal barrier dims what is under it with, a background: black. shadeAlpha says how much of it.
no setter
shadeAlpha → double
How much of shade a modal barrier blends over what is under it, from 0 (none) to 1 (all of it): 0.5 on a dark theme, 0.28 on a light one.
no setter
success → Style
What succeeded.
final
surface → Style
What stands out of the background: panels, dialogs, popups.
final
text → Style
Text.
final
warning → Style
Warnings.
final
well → Style
A well sunk into the chrome, a background: text fields. background 0.12 of the way to black on a dark theme, 0.7 of the way to white on a light one; background where it is not RGB.
no setter

Methods

copyWith({Brightness? brightness, Style? background, Style? surface, Style? text, Style? muted, Style? primary, Style? accent, Style? border, Style? selection, Style? error, Style? warning, Style? success, Style? info, Style? chrome, Style? well, Style? faint, Style? dim, Style? selectionIdle, Style? hover, Style? onPrimary, Style? shade, double? shadeAlpha, Map<int, int>? palette, PointerMode? pointerMode, Glyphs? glyphs}) → ThemeData
This theme with the fields given replaced.
fill(Color? color) → Style
A fill of color with text that reads on it, a background and a text color: a badge, a focused button, a tab or a cursor lit. Text onPrimary on primary's color, else black or white, whichever contrasts more (on a dark theme of RGB colors background's color where it reads, as on primary), a palette color measured as the terminal draws it (palette); reverse video where color is the default color, or null and primary has none.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Constants

catppuccinLatte → const ThemeData
Catppuccin Latte (catppuccin.com), its light flavor.
catppuccinMocha → const ThemeData
Catppuccin Mocha (catppuccin.com), its dark flavor: pastels on a dark blue-grey.
dark → const ThemeData
Neutral greys and muted colors on a near black.
light → const ThemeData
Neutral greys and deep colors on a near white.
nord → const ThemeData
Nord (nordtheme.com): arctic blues on a dark grey.