Put every visual decision in one file: a seed color that generates the whole ColorScheme, a TextTheme for type, constants for spacing and radius, and a ThemeExtension for colors Material lacks, such as "success". Screens never pick a color or font size by hand, and a restyle is one edit.
This guide is for Flutter developers whose app looks inconsistent or needs dark mode. It uses only Flutter SDK APIs plus google_fonts 9.0.0, as of Flutter 3.47 (October 2026).
In short:
- One seed color generates readable light and dark palettes.
- Use color roles in pairs, such as
onPrimaryonprimary. - Component themes take
CardThemeData, notCardTheme. - Fonts must cover every script your app ships.
A design token is a named decision
A token is a name for a design choice: "primary color", "medium spacing", "card radius". You write the name in the widget and keep the value in one place. A W3C community group maintains a shared file format for tokens, and Material 3 is itself described through design tokens.
In Flutter, constants plus ThemeData are enough. The payoff is consistency, cheap rebrands, and contrast you can trust.
One seed makes the color scheme
ColorScheme.fromSeed takes one color and generates every role for a given Brightness: primary and onPrimary, surface and onSurface, error, containers and outlines. The on colors are the readable foreground for their partner.
ThemeData buildTheme(Brightness brightness) => ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF6750A4),
brightness: brightness,
),
);
Pass buildTheme(Brightness.light) as theme and buildTheme(Brightness.dark) as darkTheme on MaterialApp, with themeMode: ThemeMode.system. Mixing a hand-picked hex with a scheme color throws away the contrast guarantee.
Spacing and radius are small constants
class AppSpacing {
static const xs = 4.0, s = 8.0, m = 12.0, l = 16.0, xl = 24.0, xxl = 32.0;
}
class AppRadius {
static const s = 8.0, m = 12.0, l = 16.0, xl = 24.0;
}
Six steps are plenty. If a designer asks for 13 pixels, use 12 or 16. A screen gets its rhythm from reusing the same few distances.
Component themes remove styling from widgets
ThemeData takes a theme for each component, and every widget of that type picks it up.
cardTheme: CardThemeData(
color: scheme.surfaceContainerHighest,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.m),
),
),
Use the data class, CardThemeData, here. Flutter changed cardTheme, dialogTheme and tabBarTheme to take ...ThemeData types, as the breaking change note explains. Older tutorials still show CardTheme(...), which no longer compiles.
ThemeExtension holds your own colors
Material has error but no success. ThemeExtension adds your own group. Subclass it, list the fields, and implement copyWith and lerp, which animates the colors when the theme switches.
class AppSemanticColors extends ThemeExtension<AppSemanticColors> {
const AppSemanticColors({required this.success});
final Color success;
@override
AppSemanticColors copyWith({Color? success}) =>
AppSemanticColors(success: success ?? this.success);
@override
AppSemanticColors lerp(ThemeExtension<AppSemanticColors>? other, double t) =>
other is AppSemanticColors
? AppSemanticColors(success: Color.lerp(success, other.success, t)!)
: this;
}
Register it with extensions: [AppSemanticColors(...)], with different values for light and dark, and read it with Theme.of(context).extension<AppSemanticColors>()!.
Type and fonts come from the TextTheme
Use styles by name, such as Theme.of(context).textTheme.titleLarge. The TextTheme class defines the scale. To change the font app-wide, apply it once, for example GoogleFonts.latoTextTheme(base.textTheme) from google_fonts.
That package fetches fonts over HTTP at runtime by default, and can also cache or bundle them. Before you pick a font, check it has Greek, Cyrillic or Arabic letters if you need them. Without them, text falls back to another face or shows boxes.
Four rules keep it working
- No hard-coded colors, sizes, paddings or radii inside screens.
- Use scheme roles in pairs.
- Tint with
color.withValues(alpha: 0.12)instead of a new hex. - When a screen looks wrong after a seed change, it has a hard-coded value. Fix the screen.
GrowApps keeps colors in theme.dart
The GrowApps builder's theme instructions describe this structure for generated apps: one lib/theme.dart, a fromSeed scheme, light and dark themes, spacing and radius scales, a ThemeExtension for success and warning colors, and nothing else choosing colors. A restyle request such as "more premium" or "add dark mode" is meant to be a change to that one file.
The rules also tell agents to use the ...ThemeData names and to check font coverage. See GrowApps.
Find your stray colors now
Search your project for Color(0x and Colors.. Move five of them into the theme and rerun the app. Then read how to do dark mode right.