preferences_generator 2.0.0 
preferences_generator: ^2.0.0 copied to clipboard
A powerful code generator that creates type-safe, boilerplate-free preference modules from simple abstract classes, used with `preferences_annotation`.
2.0.0 #
This is a major architectural overhaul of the Preferences Suite, introducing a more powerful,
flexible, and intuitive API. The core focus of this release is to simplify the PrefsAdapter,
automate serialization, and provide extensive configuration options for the generated code.
π Features #
- Added: Schema-in-Constructor API. Preference schemas are now defined in a private,
generative constructor (e.g., 
MySettings._({...})) instead of a factory. This enables the use of standard Dart default values. - Added: 
@PrefsModulePresets. Introduced powerful presets like.dictionary(),.syncOnly(), and.reactive()to quickly configure the generated API to match common storage backend patterns. - Added: Automatic Serialization. The generator now automatically handles the serialization
of complex types (
DateTime,Duration,Enum,Record, and custom types viaPrefConverter). ThePrefsAdapteris now only responsible for handling primitive types. - Added: 
StreamGeneration. Added the ability to generate reactiveStreams for any preference entry via the.reactive()preset or a customstreamerconfiguration. - Added: Global 
build.yamlConfiguration. You can now define project-wide settings, such askey_case: snake, to enforce conventions across all preference modules. - Added: 
KeyCaseConvention. Introduced thekeyCaseproperty in@PrefsModuleandbuild.yamlto automatically transform generated storage keys tosnake_case,kebab-case, etc. - Added: Custom 
PrefConverterSupport. Added theconverterproperty to@PrefEntryto allow users to provide a reusable class for serializing and deserializing complex custom types. - Added: Fine-Grained Method Configuration. Introduced 
CustomConfig,AffixConfig, andNamedConfigobjects to allow precise control over every generated method's name and behavior, including enabling/disabling individual methods. 
π₯ Breaking Changes #
- Refactored: The schema definition has moved from a 
factoryconstructor to a private generative constructor. The old factory-based schema is no longer supported. - Renamed: The 
PreferenceAdapterinterface has been renamed toPrefsAdapter. - Simplified: The contract for 
PrefsAdapterhas been radically simplified. It is now only required to handle primitives (String,int,double,bool,List<String>). All manual serialization logic for complex types must be removed from adapter implementations. - Removed: The 
containsKey()method has been removed from the adapter interface. - Renamed: The 
clear()method in the adapter interface has been renamed toremoveAll(). - Changed: The 
@PreferenceEntry(defaultValue: ...)property has been removed. Default values must now be provided using standard Dart syntax in the schema constructor (e.g.,String username = 'guest'). - Changed: Generated method names are now more explicit and configurable. A field named 
themewill now generate methods likegetTheme()andsetTheme(...)instead of a top-leveltheme - getter/setter pair.
 
π Bug Fixes & Improvements #
- Improved: Code generation for collection literals (
const [],const {}) now automatically infers and adds the correct type arguments to prevent type errors in the generated code. - Improved: The entire generator codebase has been refactored into a more robust and testable architecture, separating analysis, model-building, and code generation into distinct, decoupled phases.
 - Improved: Error messages are now more consistent and are all centralized in a dedicated
ExceptionHandlerclass. - Fixed: Resolved several bugs related to nullable type handling in setters and deserialization logic.
 
1.1.4 #
- Maintained: Downgraded 
source_gento be compatible with other packages. 
1.1.3 #
- Maintained: Downgraded 
buildto be compatible with other packages. 
1.1.2 #
- Updated: Updated dependencies to their latest releases.
 - Refactored: Removed deprecated code.
 
1.1.1 #
- Docs: Enhanced documentation clarity.
 
1.1.0 #
- Docs: Enhanced description clarity.
 - Refactored: Removed support for non 
dart:coredata typeColor. - Added: Added support for 
SetandDuration. - Style: Refined code formatting.
 
1.0.0 #
- Added: Initial release of 
preferences_generator. - Added: Implemented code generation for classes annotated with 
@PreferenceModule. - Added: Added support for 
int,String,double,bool,DateTime,Color,List,Map,Enum, andRecordtypes. - Added: Implemented robust error handling for common misconfigurations.