riverpod_hydrated 0.1.2
riverpod_hydrated: ^0.1.2 copied to clipboard
Riverpod extension that automatically persists and restores state using Hive storage backend.
0.1.2 #
Added #
- 🔀 State Migration System: Automatic versioning and migration support for breaking changes
- New
versiongetter to define current state structure version (defaults to 1) - New
migrate(json, fromVersion)method for handling data migrations - Version is automatically saved with state as
__version__field - Migrations are applied automatically when loading older state
- Multi-step migration support for upgrading across multiple versions
- Backward compatible: default version is 1, no migration needed for existing apps
- New
Fixed #
- 🐛 Critical: Fixed
AutoDisposeHydratedNotifierto correctly work with Riverpod 3.x- Note: In Riverpod 3.x, AutoDispose is a property of the provider, not the notifier
- Both
HydratedNotifierandAutoDisposeHydratedNotifiernow extendNotifier<State>correctly - All existing code continues to work without changes
- 🐛 Critical: Fixed race condition in dispose that could prevent state from being persisted
ref.onDispose()is now async and properly awaits write completion- Added
_flushPendingAsync()method that ensures async writes complete before disposal - Fixes issues with state loss during hot reload and rapid dispose scenarios
- Particularly important for AutoDispose notifiers and debounced writes
Changed #
- Internal implementation now uses separate mixins for better code organization
HydratedMixinBase<State>for regularNotifier<State>AutoDisposeHydratedMixin<State>for AutoDispose support- Both mixins include full migration support and all features
0.1.1 #
Improvements & Refactoring #
API Changes:
- 🔐 Simplified encryption API in
HiveHydratedStorage.build()- Replaced
encryptionCipherparameter withencrypted(boolean) andencryptionKey(List encryptionKeyis now required only whenencryptedis true- Added validation to throw
ArgumentErrorwhen encryption is enabled without a key
- Replaced
Example App:
- 📁 Refactored example application structure for better organization
- Extracted models to
lib/models/ - Extracted providers/notifiers to
lib/providers/ - Extracted widgets to
lib/widgets/ - Extracted pages to
lib/pages/ - Created barrel files for easier imports
- Extracted models to
Documentation:
- 📚 Updated README with new encryption API examples
0.1.0 #
Initial Beta Release #
Features:
- ✨ Automatic state persistence and restoration for Riverpod notifiers
- 🏗️ Support for both
NotifierandAutoDisposeNotifier - 🗄️ Hive-based storage backend with in-memory cache
- ⚡ Built-in debounce support for write optimization
- 🔒 Thread-safe operations using
synchronizedpackage - 🎯 Flexible storage key customization with suffix support
- 🛡️ Graceful error handling with
onErrorandonPersisthooks - 📊 Deep equality checking to avoid unnecessary writes
API:
HydratedNotifier<State>- Base class for persistent notifiersAutoDisposeHydratedNotifier<State>- Auto-dispose varianthydrate()- Method to restore persisted statetoJson()/fromJson()- Serialization methodsclear()- Clear persisted stateHiveHydratedStorage- Hive implementation of storage
Breaking Changes:
- None (initial release)
Known Issues:
- Hive is not safe for multi-isolate use with the same box
- Write debounce may cause state loss if app is force-killed during debounce window
For migration guides and detailed documentation, see README.md.