preferences_generator 2.0.3
preferences_generator: ^2.0.3 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_extensions
in 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.yaml
setup. - Refactored: The internal builder factory function has been renamed from
preferencesBuilder
topreferences
for better consistency and brevity.
π Documentation #
- Docs: Updated the
README.md
and migration guide to reflect the new, simplerbuild.yaml
configuration.
[2.0.1]
π Documentation #
- Improved: Overhauled the
README.md
with 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, andChangeNotifier
integration. - 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:
@PrefsModule
Presets. 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
). ThePrefsAdapter
is now only responsible for handling primitive types. - Added:
Stream
Generation. Added the ability to generate reactiveStream
s for any preference entry via the.reactive()
preset or a customstreamer
configuration. - Added: Global
build.yaml
Configuration. You can now define project-wide settings, such askey_case: snake
, to enforce conventions across all preference modules. - Added:
KeyCase
Convention. Introduced thekeyCase
property in@PrefsModule
andbuild.yaml
to automatically transform generated storage keys tosnake_case
,kebab-case
, etc. - Added: Custom
PrefConverter
Support. Added theconverter
property to@PrefEntry
to allow users to provide a reusable class for serializing and deserializing complex custom types. - Added: Fine-Grained Method Configuration. Introduced
CustomConfig
,AffixConfig
, andNamedConfig
objects 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
factory
constructor to a private generative constructor. The old factory-based schema is no longer supported. - Changed: The default generated file extension has changed from
.g.dart
to.prefs.dart
. Allpart
directives must be updated. - Renamed: The
PreferenceAdapter
interface has been renamed toPrefsAdapter
. - Simplified: The contract for
PrefsAdapter
has 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
theme
will 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
ExceptionHandler
class. - Fixed: Resolved several bugs related to nullable type handling in setters and deserialization logic.
1.1.4 #
- Maintained: Downgraded
source_gen
to be compatible with other packages.
1.1.3 #
- Maintained: Downgraded
build
to 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:core
data typeColor
. - Added: Added support for
Set
andDuration
. - 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
, andRecord
types. - Added: Implemented robust error handling for common misconfigurations.