zeba_academy_storage 0.0.1
zeba_academy_storage: ^0.0.1 copied to clipboard
A cross-platform Flutter storage utility providing secure storage, JSON persistence, cache management, and file utilities with a clean and unified API.
zeba_academy_storage #
A lightweight local storage abstraction layer for Flutter applications.
zeba_academy_storage provides a clean, testable, and platformβsafe API for managing local storage using secure storage, caching, JSON helpers, and file utilities.
β¨ Features #
- π Secure storage wrapper
- β‘ Cache manager abstraction
- π¦ JSON storage helpers
- π Platformβsafe file utilities
- π§ͺ Fully testable architecture (dependency injection)
- π Crossβplatform support (Android, iOS, Web, Windows, macOS, Linux)
π¦ Installation #
Add the package to your pubspec.yaml:
dependencies:
zeba_academy_storage: ^0.0.1
Then run:
flutter pub get
π Getting Started #
Import the package:
import 'package:zeba_academy_storage/zeba_academy_storage.dart';
π Secure Storage Example #
Store sensitive data securely:
final secureStorage = SecureStorage();
await secureStorage.write('token', '12345');
final token = await secureStorage.read('token');
print(token);
β‘ Cache Manager Example #
Save and read cached values:
final cache = CacheManager();
await cache.write('username', 'sarvesh');
final name = await cache.read('username');
π¦ JSON Storage Example #
Store structured data easily:
final jsonStorage = JsonStorage(CacheManager());
await jsonStorage.saveJson('user', {
'name': 'Sarvesh',
'role': 'student'
});
final data = await jsonStorage.readJson('user');
print(data?['name']);
π File Utilities #
Platformβsafe file handling utilities:
final path = await FileUtils.getAppDirectory();
print(path);
π§ͺ Testing (Mock Storage) #
The package is designed with dependency injection, allowing easy unit testing.
Example mock:
class MockStorage implements KeyValueStorage {
final Map<String, String> _data = {};
@override
Future<void> write(String key, String value) async => _data[key] = value;
@override
Future<String?> read(String key) async => _data[key];
@override
Future<void> delete(String key) async => _data.remove(key);
@override
Future<void> clear() async => _data.clear();
}
π Architecture #
JsonStorage
β
KeyValueStorage (interface)
β
βββββββββββββββββ¬βββββββββββββββββ
β CacheManager β SecureStorage β
βββββββββββββββββ΄βββββββββββββββββ
This design ensures:
- Clean separation of concerns
- Pluginβsafe unit testing
- Easy extensibility
π Supported Platforms #
| Platform | Supported |
|---|---|
| Android | β |
| iOS | β |
| Web | β |
| Windows | β |
| macOS | β |
| Linux | β |
π API Overview #
KeyValueStorage #
| Method | Description |
|---|---|
| write | Save value |
| read | Read value |
| delete | Remove key |
| clear | Clear storage |
π€ Contributing #
Contributions are welcome!
- Fork the repository
- Create a feature branch
- Commit changes
- Submit a pull request
π Issues #
If you find a bug or want a feature, please open an issue in the repository.
π License #
This project is licensed under the GPL License.
β€οΈ Maintained by #
Zeba Academy
Built with Flutter for scalable application development.