preferences_generator 2.0.5
preferences_generator: ^2.0.5 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.3 #
🐛 Bug Fixes #
- Fixed: Resolved a critical crash that occurred when a user customized
build_extensionsin theirbuild.yaml. The generator no longer manually parses this option and now correctly defers tobuild_runner's standard mechanism.
2.0.2 #
🔧 Improvements & Maintenance #
- Improved: Simplified the builder configuration for end-users. The builder is now consistently
named
preferences_generator(matching the package name), which allows for a more conventionalbuild.yamlsetup. - Refactored: The internal builder factory function has been renamed from
preferencesBuildertopreferencesfor better consistency and brevity.
📚 Documentation #
- Docs: Updated the
README.mdand migration guide to reflect the new, simplerbuild.yamlconfiguration.
2.0.1 #
📚 Documentation #
- Improved: Overhauled the
README.mdwith a new, comprehensive "Configuration in Depth" section. The update adds detailed documentation and examples for all advanced features, including module presets, method configuration, key casing, reactive streams, andChangeNotifierintegration. - Improved: Refined presentation and clarity of the main README with tables and blockquotes for better scannability.
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. - Changed: The default generated file extension has changed from
.g.dartto.prefs.dart. Allpartdirectives must be updated. - 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.