easy_local_secure_storage 0.0.1
easy_local_secure_storage: ^0.0.1 copied to clipboard
A simple and secure key-value storage service for Flutter apps.
# π‘οΈ easy_local_secure_storage
A simple, lightweight, and reactive **Flutter Secure Storage** wrapper that supports:
- β
Enum or String-based keys
- β
JSON read/write helpers
- β
Reactive `Stream` updates (per key and global)
- β
Works seamlessly on Android & iOS
- β
Fully secure using `flutter_secure_storage`
---
## π Installation
Add this to your **`pubspec.yaml`**:
```yaml
dependencies:
easy_local_secure_storage: ^1.0.0
Then run:
flutter pub get
π§± Import #
import 'package:easy_local_secure_storage/easy_local_secure_storage.dart';
βοΈ Basic Usage #
Write & Read Values #
await EasyLocalSecureStorage.write("token", "abc123");
final token = await EasyLocalSecureStorage.read("token");
print("Token: $token");
Delete a Key #
await EasyLocalSecureStorage.delete("token");
Clear All Stored Keys #
await EasyLocalSecureStorage.clear();
π§© Enum or String Keys #
You can define your own enums freely β no need to modify the package.
enum UserKeys { uid, token, email }
await EasyLocalSecureStorage.write(UserKeys.token, "xyz987");
final value = await EasyLocalSecureStorage.read(UserKeys.token);
print(value); // xyz987
π§ JSON Storage Support #
Easily store and retrieve entire objects as JSON strings.
await EasyLocalSecureStorage.writeJson("userProfile", {
"name": "User",
"email": "User@example.com",
});
final user = await EasyLocalSecureStorage.readJson("userProfile");
print(user?['name']); // User
π₯ Reactive Stream Updates #
1οΈβ£ Listen for a Single Key #
EasyLocalSecureStorage.stream("theme").listen((value) {
print("Theme changed: $value");
});
// Trigger updates
await EasyLocalSecureStorage.write("theme", "dark");
await EasyLocalSecureStorage.write("theme", "light");
await EasyLocalSecureStorage.delete("theme");
Output:
Theme changed: dark
Theme changed: light
Theme changed: null
2οΈβ£ Use with Flutterβs StreamBuilder #
You can directly use a stream in a widget to update the UI reactively:
StreamBuilder<String?>(
stream: EasyLocalSecureStorage.stream("theme"),
builder: (context, snapshot) {
final theme = snapshot.data ?? "default";
return Text("Current theme: $theme");
},
);
Whenever the value of "theme" changes,
the widget rebuilds automatically π
3οΈβ£ Listen for Any Key Change (Global Stream) #
EasyLocalSecureStorage.onAnyChange.listen((event) {
print("Key '${event.key}' changed β ${event.value}");
});
Output:
Key "token" changed β abc123
Key "theme" changed β dark
Key "theme" changed β null
π§° Additional Helpers #
Get All Keys #
final keys = await EasyLocalSecureStorage.listKeys();
print(keys);
Read All Key-Value Pairs #
final all = await EasyLocalSecureStorage.readAll();
print(all);
π§Ό Cleanup (optional) #
If you use streams and want to close them manually (e.g., during app shutdown):
EasyLocalSecureStorage.dispose();
π Platform Support #
| Platform | Supported | Secure Backend |
|---|---|---|
| Android | β | EncryptedSharedPreferences |
| iOS | β | Keychain |
π§βπ» Example #
A complete example app is included in the /example directory.
Run:
flutter run example
π¦ Changelog #
v1.0.0 #
- Added Enum & String key support
- Added JSON read/write helpers
- Added reactive streams (per key + global)
- Added listKeys, readAll, and dispose support
- Improved key resolution and error handling
β€οΈ Contributing #
- Fork this repo
- Create a new branch (
feature/my-feature) - Commit your changes
- Open a PR
π License #
MIT License Β© 2025 shindekalpesharun
Secure. Simple. Reactive.
Use easy_local_secure_storage to make secure local storage effortless in Flutter.
---
Would you like me to include **pub.dev-style badges** (version, likes, pub points, license, etc.) and a **Flutter example screenshot or GIF** section next?
Itβll make your package page look polished and professional like official Flutter packages.