zeba_academy_offline_cache 1.0.0 copy "zeba_academy_offline_cache: ^1.0.0" to clipboard
zeba_academy_offline_cache: ^1.0.0 copied to clipboard

A lightweight and powerful offline caching solution for Flutter. Supports cache-first and network-first strategies with auto expiry, built for offline-first apps, e-commerce, and content platforms.

šŸ“¦ zeba_academy_offline_cache #

A lightweight, powerful, and flexible offline caching solution for Flutter apps.

Designed for offline-first applications, this package enables seamless data access even without internet connectivity.


✨ Features #

  • ⚔ Cache network requests for offline use
  • šŸ”„ Auto expiry & refresh mechanism
  • šŸŽÆ Multiple cache policies (cache-first, network-first, etc.)
  • 🧩 Supports JSON, images, and extendable for videos
  • 🪶 Lightweight storage using Hive
  • šŸš€ Simple and clean API

šŸ“¦ Installation #

Add this to your pubspec.yaml:

dependencies:
  zeba_academy_offline_cache: ^1.0.0

šŸš€ Getting Started #

1. Initialize Storage #

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await StorageService.init();
  runApp(MyApp());
}

2. Fetch Data with Cache #

final data = await CacheManager.fetch(
  url: "https://jsonplaceholder.typicode.com/posts",
  policy: CachePolicy.cacheFirst,
  expiry: Duration(minutes: 10),
);

šŸŽÆ Cache Policies #

Policy Description
cacheFirst Uses cache first, falls back to network
networkFirst Uses network first, falls back to cache
cacheOnly Only returns cached data
networkOnly Always fetches from network

šŸ“¦ Example #

final result = await CacheManager.fetch(
  url: "https://api.example.com/data",
  policy: CachePolicy.networkFirst,
);

print(result);

🧠 Use Cases #

  • šŸ“± Offline-first mobile apps
  • šŸ›’ E-commerce apps
  • šŸ“° Content/news apps
  • šŸ“š Learning platforms

āš™ļø Advanced Usage #

Custom Expiry #

await CacheManager.fetch(
  url: "https://api.example.com/data",
  expiry: Duration(hours: 1),
);

Clear Cache #

await StorageService.clear();

šŸ› ļø Roadmap #

  • šŸ”„ Background sync
  • šŸ“” Connectivity-aware caching
  • šŸ–¼ļø Advanced image & video caching
  • šŸ” Secure storage (encryption)

šŸ¤ Contributing #

Contributions are welcome! Feel free to open issues or submit pull requests.


šŸ“„ License #

This project is licensed under the GPL License.


šŸ‘Øā€šŸ’» About Me #

✨ I’m Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects. You can learn more about me and my work at sufyanism.com or connect with me on Linkedin


🌐 Your all-in-one no-bloat hub! #

šŸš€ Explore cutting-edge resources in coding, tech, and development at zeba.academy and code.zeba.academy. Empower yourself with practical skills through curated directives, real-world projects, and hands-on experience. Level up your tech game today! šŸ’»āœØ

Zeba Academy is a learning platform dedicated to coding, technology, and development. āž” Visit our main site: zeba.academy āž” Explore hands-on courses and resources at: code.zeba.academy āž” Check out our YouTube for more tutorials: zeba.academy āž” Follow us on Instagram: zeba.academy


Thank you for visiting!

0
likes
120
points
79
downloads

Documentation

API reference

Publisher

verified publisherzeba.academy

Weekly Downloads

A lightweight and powerful offline caching solution for Flutter. Supports cache-first and network-first strategies with auto expiry, built for offline-first apps, e-commerce, and content platforms.

Homepage

Topics

#cache #offline #networking #hive #flutter

License

GPL-3.0 (license)

Dependencies

flutter, hive, hive_flutter, http, path_provider

More

Packages that depend on zeba_academy_offline_cache