prf 2.1.0
prf: ^2.1.0 copied to clipboard
Easily save and load values locally. Effortless local persistence with type safety and zero boilerplate. Just get, set, and go. Designed to fully replace raw use of SharedPreferences
Changelog #
All notable changes to the prf package will be documented in this file.
2.1.0 #
Added #
PrfCooldownutility for managing persistent cooldown periods with built-in tracking and duration handlingPrfRateLimiterindustry-grade token bucket limiter usingprftypes for rolling-rate restrictions (e.g.1000 actions per 15 minutes)- New typed variables:
PrfTheme– store theme mode (light,dark,system)PrfDuration– storeDurationas microsecondsPrfBigInt– storeBigIntas a string
removeAll()method inPrfCooldownandPrfRateLimiterto clear all related sub-keysoverrideWith()andresetOverride()methods inPrfto inject customSharedPreferencesAsyncinstance for testing- Detailed migration documentation for:
- Migrating from
SharedPreferences - Migrating from
SharedPreferencesAsync - Migrating from legacy
prf
- Migrating from
- README coverage for isolate support and compatibility
Changed #
- Internal singleton of
Prfnow supports override injection for better testability - Updated comparison table in README to highlight isolate safety, caching, and type support
Fixed #
- Deprecated
Prf.clear(...)to discourage unintentional global wipes — usePrf.instance.clear()instead for clarity and safety
2.0.0 #
Internals migrated to SharedPreferencesAsync #
🚨 Behavioral Breaking Change (no API changes)
TL;DR — Do You Need to Do Anything? #
- ✅ No action needed if:
- Your app is new and doesn't rely on previously stored values, or
- You were already using
SharedPreferencesAsync— everything will continue to work seamlessly.
- 🔁 Run a migration if:
- Your app was using
prfprior to this version (pre-2.0.0) - You want to preserve previously stored values
- Your app was using
await Prf.migrateFromLegacyPrefsIfNeeded();
🧠 Why this change? #
prf now uses SharedPreferencesAsync under the hood — the new, isolate-safe, officially recommended backend for shared preferences.
This change future-proofs prf and avoids issues caused by the old SharedPreferences API, which:
- Is being deprecated
- Is not isolate-safe
- Does not guarantee disk persistence on write (source)
🛠 Migration Instructions #
If your app used prf previously and stored data you want to keep:
await Prf.migrateFromLegacyPrefsIfNeeded();
This safely copies data from the legacy storage backend to the new one.
It’s safe to run every time — the migration will only happen once.
✅ What’s new in 2.0.0: #
- Internals now use
SharedPreferencesAsync - Full isolate-safety, suitable for background plugins like
firebase_messaging - Removed reliance on
getInstance()and internal platform-side caching prfnow fully controls its own cache- Public API is unchanged —
get(),set(),remove()all still work the same
🔁 Key Differences #
| Feature | Before (1.x) |
After (2.0.0) |
|---|---|---|
| Backend | SharedPreferences (legacy) | SharedPreferencesAsync |
| Android storage method | SharedPreferences XML | DataStore Preferences |
| Isolate-safe | ❌ No | ✅ Yes |
💬 Summary #
This is a critical under-the-hood upgrade to ensure prf is compatible with modern Flutter apps, isolate-safe, and ready for the future of shared preferences.
If your app is new, or you don’t care about previously stored data — you're done ✅
If you’re upgrading and need old values — migrate once as shown above.
1.3.8 #
- Added example file for pub.dev to showcase package usage.
1.3.7 #
- Finished setting up for publishing, this package was private for too long in my repositoriee, hope you enjoy it!
1.3.6 #
- Added omprehensive documentation comments for the entire library.
- Improved API reference with examples and usage notes.
- Enhanced dartdoc coverage for all public classes and methods.
- Better explanation of advanced features and type support.
1.3.5 #
- Improved
PrfDateTimeencoding reliability by enforcing endian order consistency. - Fixed internal handling of corrupted
base64data forPrfBytes.
1.3.4 #
Added #
PrfJson<T>class for storing JSON-serializable objects usingjsonEncode/jsonDecode.- Graceful fallback when decoding invalid JSON or mismatched types.
1.3.3 #
Added #
PrfDateTimeusing base64-encoded 64-bit integers to persistDateTimevalues with millisecond precision.- Integrated with
PrfEncodedto reduce redundant logic.
1.3.2 #
Added #
PrfEncoded<TSource, TStore>for reusable value transformation between domain objects and SharedPreferences-compatible types.- Supports encoding formats like JSON, binary, and base64.
1.3.1 #
Improved #
- Added
_existscheck insidegetValue()to allow fallback todefaultValueif key is missing. - Improved caching logic to avoid unnecessary SharedPreferences reads.
1.3.0 #
1.2.0 #
Added #
PrfByteswith transparent base64 storage ofUint8List.- Full support for all native SharedPreferences types:
PrfIntPrfDoublePrfBoolPrfStringPrfStringList
Improved #
- Unified all variable types using delegate-based constructors.
- Internal logic now handles nullability consistently and efficiently.