Start Debugging

theming

3 posts

2026-10-19 flutterdarttheming

How to Define Custom Design Tokens with ThemeExtension and Animate Them Between Light and Dark Themes in Flutter

Subclass ThemeExtension, register one instance per ThemeData through the extensions list, read it with Theme.of(context).extension<T>(), and write a real lerp so MaterialApp's AnimatedTheme interpolates your tokens during a light/dark switch. Covers colors, radii, shadows, text styles and booleans, the missing-extension crash, the copyWith trap that drops every other extension, and why you need == and hashCode, all verified with widget tests on Flutter 3.44.8.