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!

  1. Fork the repository
  2. Create a feature branch
  3. Commit changes
  4. 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.