Design Tokens
Customize Flutter themes, semantic colors, typography, spacing, and component sizes.
Theme architecture
The public compatibility file is lib/components/utils/design_tokens.dart. It re-exports the modular theme registry under components/utils/themes/.
components/utils/themes/
├── app_theme.dart
├── base/design_tokens_model.dart
└── definitions/modern_theme.dart
retro_theme.dart
cozy_theme.dart
paper_theme.dartAppThemeRegistry currently supports modern, retro, cozy, and paper, each with light/dark token definitions.
Use tokens in widgets
final tokens = ref.watch(designTokensProvider);
Container(
padding: EdgeInsets.all(tokens.contentPadding),
decoration: BoxDecoration(
color: tokens.surface,
borderRadius: BorderRadius.circular(tokens.cardBorderRadius),
),
child: Text('Hello', style: tokens.bodyPrimary),
);DesignTokens includes semantic colors, body text styles, border radii, spacing/padding, layout values, component sizes, border colors, and card shadows. Use these values instead of hard-coded colors and dimensions.
Runtime appearance
providers/theme_provider.dart persists:
AppThemeMode: light, dark, or system.AppTheme: modern, retro, cozy, or paper.AccentColor: emerald, blue, indigo, purple, pink, or amber.- Text scale, bold text, reduced motion, and compact mode.
Appearance settings are local and available in both Account and Guest profiles.
Add a theme
- Add an enum value to
AppThemeincomponents/utils/themes/app_theme.dart. - Create complete light/dark
DesignTokensvalues underthemes/definitions/. - Register both values in
AppThemeRegistrymaps. - Add the option/translation to the appearance page and ARB files.
- Regenerate provider/localization code as needed.
- Test contrast, text scaling, compact spacing, reduced motion, and both brightness modes.
Do not edit generated provider files by hand. Keep all required DesignTokens fields populated.
Relevant files
components/utils/design_tokens.dartcomponents/utils/themes/base/design_tokens_model.dartcomponents/utils/themes/app_theme.dartcomponents/utils/themes/definitions/providers/theme_provider.dartpages/settings/appearance/page.dart
