best_theme_generator 2.0.0
best_theme_generator: ^2.0.0 copied to clipboard
A code generation package for creating theme color variables in Flutter.
Changelog #
All notable changes to this project will be documented in this file.
2.0.0 - 2026-03-06 #
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.
1.2.0 - 2025-12-15 #
- Fix issue of set theme mode from ThemeData
1.1.0 - 2025-11-15 #
- you can use context.BestTheme also for routers
1.0.2 - 2025-10-29 #
- Fix issue of generating
1.0.1 - 2025-10-29 #
- Use last best_theme version
1.0.0 - 2025-10-29 #
- Updated dependencies for better compatibility and stability
- Improved support for modern Flutter and Dart projects
- Cleaned up pubspec.yaml
0.0.7 2025-9-9 #
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
0.0.2 - 2024-10-31 #
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)