preferences_annotation 3.0.0
preferences_annotation: ^3.0.0 copied to clipboard
Annotations and interfaces for generating type-safe, boilerplate-free preference management classes.
3.0.0 #
💥 Breaking Changes #
- Removed:
AffixConfig,CustomConfig, andNamedConfigconfiguration classes have been deleted entirely.config.dartis no longer exported. - Changed: All per-entry method configuration parameters on
@PrefEntry(getter,setter,remover,asyncGetter,asyncSetter,asyncRemover,streamer) now accept aString?template instead of aCustomConfigobject. Templates use{{name}}and{{Name}}tokens for substitution. - Changed: All per-entry method configuration parameters on
@PrefsModule(getter,setter,remover,asyncGetter,asyncSetter,asyncRemover,streamer) now accept aString?template.nullmeans disabled across the module. - Changed: Module-level method parameters (
removeAll,refresh) on@PrefsModulenow accept a plainString?(the literal method name).nullmeans disabled. - Renamed:
@PrefsModule.testing()is now@PrefsModule.exhaustive(). The.exhaustive()preset generates all method variants with consistent, predictable naming. - Changed: All preset constructors now accept
void Function(Object, StackTrace)? onWriteErrorinstead of typed config objects.
🚀 New Features #
- Added:
@PrefEntry(readOnly: true)— a first-class shorthand that disables all write methods (setter, asyncSetter, remover, asyncRemover) for a single entry. Equivalent to passingPrefEntry.disabledto all four write-method parameters. - Added:
PrefEntry.disabled— a sentinel constant (String) that can be passed to any method template parameter on@PrefEntryto force-disable that method for this entry only, overriding the module default. - Added:
@PrefsModule.minimal()preset — generates only synchronous getters, setters, and removers with no async variants, no streams, and no module-level methods. Ideal for CLI tools and scripts. - Added:
@PrefsModule(onWriteError: myHandler)— an optional callbackvoid Function(Object, StackTrace)invoked when a synchronous (fire-and-forget) write fails. Defaults tonull(silent discard). - Added:
prefsMinimalModuleconvenience constant inconstants.dart.
📚 Documentation #
- Added prominent documentation for the "no null distinction" limitation:
with
containsKeyremoved from the adapter contract there is no way to distinguish a nullable field that was never written from one explicitly set tonull. - All annotation parameters are fully documented with token descriptions and code examples.
🔧 Maintenance #
- Minimum Dart SDK constraint remains
^3.10.0.
2.0.1 #
📚 Documentation #
- Improved: Updated the
README.mdto clearly list and describe all new API components introduced in the v2.0.0 release, includingPrefConverter,KeyCase, and the configuration 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.