preferences_annotation 2.0.0
preferences_annotation: ^2.0.0 copied to clipboard
Annotations and interfaces for generating type-safe, boilerplate-free preference management classes.
2.0.0 #
π Features #
- Added:
@PrefsModulePresets. The module annotation now includes powerful presets like.dictionary(),.syncOnly(), and.reactive()to quickly configure the generated API. - Added:
KeyCaseEnum & Configuration. Introduced theKeyCaseenum and akeyCaseproperty on@PrefsModuleto allow for conventional, automatic naming of storage keys (e.g.,snake_case). - Added:
PrefConverterInterface. A new interface for creating reusable, type-safe serializers for custom classes. - Added: Configuration Classes. Introduced
CustomConfig,AffixConfig, andNamedConfigto provide fine-grained control over generated method names and behavior directly within the@PrefEntryannotation.
π₯ Breaking Changes #
- Renamed: The
@PreferenceModuleannotation has been renamed to@PrefsModulefor better consistency. - Renamed: The
PreferenceAdapterinterface has been renamed toPrefsAdapter. - Changed: The
PrefsAdapterinterface contract has been significantly simplified. It is now only responsible for handling primitive types (String,int,double,bool,List<String>). All serialization logic for complex types is now handled by the generator. - Removed: The
containsKey()method has been removed from thePrefsAdapterinterface. - Renamed: The
clear()method in the adapter interface has been renamed toremoveAll(). - Changed: The schema definition API is completely new, moving from a
factoryconstructor to a private generative constructor. - Removed: The
@PreferenceEntry(defaultValue: ...)property has been removed. Default values must now be defined using standard Dart syntax within the new private schema constructor (e.g.,String username = 'guest'). - Removed: The
@PreferenceIgnoreannotation is now obsolete and has been removed. The new "opt-in" schema (where only parameters in the private constructor are included) makes it redundant.
π Bug Fixes & Improvements #
- Improved: All annotations are now immutable, with
constconstructors for better performance. - Docs: Comprehensive documentation has been added for every new class, enum, and property.
- Refactored: The package has been streamlined to contain only the essential public API, with all implementation details residing in the generator.
1.1.0 #
- Added: Added
@PreferenceIgnoreannotation to exclude fields from preference processing. - Added: Added convenience constants for all annotations (
prefModule,prefEntry, andprefIgnore). - Docs: Enhanced documentation for all classes and interfaces.
- Maintained: Improved
pubspec.yamlwith additional package information. - Refactored: Removed Flutter-specific references for pure Dart compatibility.
1.0.3 #
- Maintained: Updated dependencies to their latest releases.
1.0.2 #
- Maintained: Updated dependencies to their latest releases.
1.0.1 #
- Docs: Enhanced description clarity.
1.0.0 #
- Added: Initial release of
preferences_annotation. - Added:
@PreferenceModuleannotation for defining settings modules. - Added:
@PreferenceEntryannotation for defining persistent preference values. - Added:
PreferenceAdapterabstract interface for storage backend integration.