Theme
Shares a ThemeData with its subtree. Read it with Theme.of(context)
or the context.theme shorthand (which fall back to ThemeData.fallback
when absent, so widgets can always resolve a theme without a required
ancestor).
Learn more: Theming
Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.
// Override the theme for one subtree, starting from the one above it:Theme( data: Theme.of(context).copyWith(borderStyle: BorderStyle.double), child: child,)
// Any descendant reads the nearest theme:final primary = Theme.of(context).colorScheme.primary;Details
Section titled “Details”An app usually sets its theme once, with FleuryApp(theme: ...), which installs a Theme above the whole app. Nest another Theme to restyle one subtree. The inner theme replaces the outer one below it; nothing is merged, so derive it from the enclosing theme to change only some fields.
Wrapping a subtree in a Theme also cascades ThemeData.textStyle as
the DefaultTextStyle, so a base text color/dim can be set app-wide in
one place.
Constructors
Section titled “Constructors”Theme()
Section titled “Theme()”| Parameter | Type | Default | Description |
|---|---|---|---|
data: | ThemeData | required | The theme for everything below this widget, replacing any theme above it rather than merging with it. More |
child: | Widget | required | The subtree that reads data. |
data: Descendants read it withTheme.of,context.theme, orcontext.colors(itsThemeData.colorScheme), and those readers rebuild whendatachanges (compared with==). To override only a few fields, pass the enclosing theme’sTheme.of(context).copyWith(...), read where you build this widget. ItsThemeData.textStylelikewise replaces the subtree’sDefaultTextStyle.
Source
Section titled “Source”Theme is defined in packages/fleury/lib/src/widgets/theme.dart.
Category: App & theming · All widgets