best_theme_generator
A code generation package for creating theme color variables in Flutter.
3.0.5
dosty17/best_theme
What this package is like to depend on
Last release 2 months ago
19 Jun 2026
Release timing varies
gaps range from 2 weeks to 8 months
Some releases are documented
notes for 15 of 27 stable releases
Nothing withdrawn
no release was ever pulled
2 years old
27 releases · first in 2024
22 releases in the last 12 months
see the full history below
Release timeline
27 releases · Dec 2024 to Jun 2026Releases
latest 27-
3.0.519 Jun 2026 -
3.0.419 Jun 2026Nothing published for this version
-
3.0.319 Jun 2026Nothing published for this version
-
3.0.219 Jun 2026Nothing published for this version
-
3.0.119 Jun 2026 -
3.0.019 Jun 2026Release notes
Open source →Breaking Changes
- Migrated the code generation engine to parse theme tokens directly from
static constclass fields. - Removed the legacy annotation-driven variable collection mechanism.
- Removed internal runtime parameter maps and array-based token registration.
- Eliminated factory constructors that relied on dynamic token arrays.
- Reduced runtime allocations and removed lookup-related null reference issues.
Added
-
Automatic detection and generation of:
BestColorBestTextStyleBestAsset
-
Multi-token grouping support for colors, typography, and assets.
-
Asynchronous storage lifecycle support through
BestThemeStorage. -
Automatic theme mode persistence integration.
-
Improved generated state management architecture.
-
Safe extension bundling after custom theme overrides.
-
Generated extensions are now appended after
buildLightTheme()andbuildDarkTheme()execution, preventing accidental loss of generated theme extensions. -
Improved compile-time performance and code generation reliability.
Fixed
- Full compatibility with Analyzer 6.x and 7.x.
- Fixed AST scanning issues caused by analyzer API changes.
- Fixed build failures related to the
fields2architecture migration. - Improved generator stability across newer Dart SDK versions.
Migration Guide
Old (v2.x.x)
final colors = [ BestColor( name: 'primary', light: Colors.blue, dark: Colors.indigo, ), ]; class MyTheme extends _$MyTheme { MyTheme() : super(myColors: colors); }New (v3.0.0)
@BestTheme( extensionName: 'appTheme', ) class MyTheme extends _$MyTheme { static const primary = BestColor( light: Colors.blue, dark: Colors.indigo, ); static const titleLarge = BestTextStyle( light: TextStyle(fontSize: 24), dark: TextStyle(fontSize: 24), ); static const appLogo = BestAsset( light: 'assets/logo_light.png', dark: 'assets/logo_dark.png', ); }
- Migrated the code generation engine to parse theme tokens directly from
-
2.0.006 Mar 2026Release notes
Open source →Breaking Changes
- Complete architecture redesign: Generator now produces a
ThemeExtension-based class (_${ClassName}Theme extends ThemeExtension) instead of the previous singleton pattern. Generated code is no longer compatible with1.xusage. - Removed: singleton (
init(),instance),ValueNotifier/ThemeParam,BestThemeProvider,BestThemeBuilder, static color getters, and thecontext.BestTheme()/context.BestThemeRouter()wrappers. - Removed:
toggleColor(),toDark(),toLight(),toSystem(),adanceToggle()instance methods.
Added
ThemeExtensiongeneration: generates@immutable _${ClassName}Theme extends ThemeExtensionwithcopyWith,lerp,.light(colors)factory,.dark(colors)factory, andstatic of(context).${ClassName}BestThemeMaterialwidget: standaloneStatefulWidget— no object instantiation needed. Pass it abuilder: (context, mode, lightTheme, darkTheme)and use directly as the app root.buildLightTheme/buildDarkThemeoverridable hooks on the generated_$ClassNamebase class. Receives the pre-builtThemeData(with extension already injected) so users cancopyWithfonts, color schemes, app bar themes, etc. without re-declaring extensions.extensionNameannotation support: readsextensionNamefrom@BestThemeto name theBuildContextgetter (e.g.context.appColors).- New
BuildContextextension methods:toDark(),toLight(),toggleTheme(),setThemeMode(mode),isDark,scaffoldBackgroundColor,primary,primaryScheme.
Changed
- Color access moved from
context.myColors.colorNametocontext.{extensionName}.colorNamevia Flutter'sTheme.of(context).extension<_${ClassName}Theme>(). - Theme state is now managed by
StatefulWidget(_${ClassName}BestThemeMaterialState) instead of aValueNotifiersingleton — fully compatible with Flutter's widget lifecycle.
- Complete architecture redesign: Generator now produces a
-
1.2.015 Dec 2025 -
1.1.015 Nov 2025 -
1.0.929 Oct 2025Nothing published for this version
-
1.0.829 Oct 2025Nothing published for this version
-
1.0.729 Oct 2025Nothing published for this version
-
1.0.629 Oct 2025Nothing published for this version
-
1.0.529 Oct 2025Nothing published for this version
-
1.0.429 Oct 2025Nothing published for this version
-
1.0.329 Oct 2025Nothing published for this version
-
1.0.229 Oct 2025 -
1.0.129 Oct 2025 -
1.0.029 Oct 2025Release notes
Open source →- Updated dependencies for better compatibility and stability
- Improved support for modern Flutter and Dart projects
- Cleaned up pubspec.yaml
-
0.0.927 Sep 2025Nothing published for this version
-
0.0.827 Sep 2025Nothing published for this version
-
0.0.709 Sep 2025Release notes
Open source →Added
- Singleton Pattern Implementation: Implemented singleton pattern with
init()andinstancegetters for better memory management - Context Extensions Generation: Auto-generates BuildContext extensions for seamless theme access
- Static Color Getters: Generated static methods for accessing colors (
get[ColorName]) - Enhanced Router Support: Improved
BestThemeRoutermethod with comprehensive MaterialApp.router support - Performance Optimizations: Better initialization and memory management patterns
- Rich Documentation: Enhanced inline documentation and code comments in generated files
Changed
- BREAKING: Complete architecture redesign from object-based to context-based approach
- Generated Code Structure: Completely restructured generated code for better organization
- API Surface: Transformed from manual instantiation to automatic singleton management
- Initialization Process: Changed from constructor-based to static initialization pattern
- Color Access Pattern: Moved from wrapper widgets to direct context access via extensions
Improved
- Type Safety: Enhanced null safety and assertion handling in generated code
- Developer Experience: Significantly simplified usage patterns with context extensions
- Code Generation Quality: Better formatted and organized generated code
- Error Handling: Improved error messages and debugging information
- Runtime Performance: Optimized theme switching and color access patterns
Enhanced
- Code Aesthetics: Beautiful header with generation timestamp and developer credits
- Documentation Generation: Comprehensive inline documentation for all generated methods
- Method Signatures: Improved method signatures and parameter handling
- Extension Methods: Rich set of BuildContext extensions for theme management
- Class Structure: Better organized class hierarchy and method grouping
Technical Improvements
- Generated Header: Added decorative ASCII art header with metadata
- Singleton Management: Implemented proper singleton pattern with lazy initialization
- Context Integration: Deep integration with Flutter's BuildContext system
- Static Analysis: Better code generation for static analysis tools
- Memory Management: Improved memory usage patterns in generated code
Generated Features
context.myColors.[colorName]- Direct color accesscontext.isDark- Theme state checkingcontext.toggleTheme()- Theme togglingcontext.BestTheme()- App wrapper creationcontext.BestThemeRouter()- Router app wrapper- Static color getters for each defined color
- Automatic singleton initialization
- Singleton Pattern Implementation: Implemented singleton pattern with
-
0.0.624 Jan 2025 -
0.0.519 Jan 2025 -
0.0.419 Jan 2025 -
0.0.329 Dec 2024 -
0.0.225 Dec 2024Release notes
Open source →Added
- Initial release of
best_theme_generatorpackage. - Support for generating theme classes based on annotations.
- Automatic variable generation for color themes defined in
DostyColor. @BestThemeannotation to create theme structures with light and dark modes.- Generated code for easy access to defined colors via variable names.
- Support for theme mode toggling (light, dark, system) in the generated class.
Fixed
- N/A (First release)
Changed
- N/A (First release)
- Initial release of