dio_cache_ttl 0.3.2 copy "dio_cache_ttl: ^0.3.2" to clipboard
dio_cache_ttl: ^0.3.2 copied to clipboard

A Dio-based caching solution with Time-to-Live (TTL) support, enabling efficient storage and retrieval of HTTP responses using the file system. Ideal for optimizing network performance and reducing re [...]

dio_cache_ttl #

A Dio-based caching solution with Time-to-Live (TTL) support, enabling efficient storage and retrieval of HTTP responses using the file system. Ideal for optimizing network performance and reducing redundant requests.

Features #

✅ Cache files locally with a specified TTL ✅ Uses Dio for efficient downloading ✅ Automatically clears expired cache ✅ Supports custom cache directories

Installation #

Add this to your pubspec.yaml:

dependencies:
  dio_cache_ttl: ^0.3.3

Or add via CLI:

flutter pub add dio_cache_ttl
dependencies:
  dio_cache_ttl:
    git:
      url: https://github.com/cas8938/dio_cache_ttl.git

Usage #

Import the package #

import 'package:dio_cache_ttl/dio_cache_ttl.dart';

Cache a file #

import 'dart:io';
import 'package:dio_cache_ttl/dio_cache_ttl.dart';

void main() async {
  File file = await dioCache(
    "https://example.com/sample.pdf",
    extFile: "pdf",
    ttl: Duration(hours: 1), // Cache for 1 hour
  );
  print("File saved at: ${file.path}");
}

Testing #

Run tests using:

flutter test

License #

This project is licensed under the MIT License - see the LICENSE file for details.

1
likes
150
points
33
downloads

Publisher

verified publisherflagodna.com

Weekly Downloads

A Dio-based caching solution with Time-to-Live (TTL) support, enabling efficient storage and retrieval of HTTP responses using the file system. Ideal for optimizing network performance and reducing redundant requests.

Repository (GitHub)
View/report issues

Topics

#cache #ttl #dio #file

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

dio, flutter, path_provider

More

Packages that depend on dio_cache_ttl