easy_local_secure_storage 0.0.1+1 copy "easy_local_secure_storage: ^0.0.1+1" to clipboard
easy_local_secure_storage: ^0.0.1+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:

dependencies:
  easy_local_secure_storage: ^0.0.2

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 #

v0.0.1 #

  • 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.


---

MIT License

Copyright (c) 2025 shindekalpesharun

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

2
likes
120
points
3
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A simple and secure key-value storage service for Flutter apps.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_secure_storage

More

Packages that depend on easy_local_secure_storage