# πŸ›‘οΈ 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

  1. Fork this repo
  2. Create a new branch (feature/my-feature)
  3. Commit your changes
  4. 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.