dio_cache_ttl 0.3.2
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 [...]
import 'dart:io';
import 'package:dio_cache_ttl/dio_cache_ttl.dart';
void main() async {
const url =
'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
const cacheDuration = Duration(minutes: 5);
try {
File file = await dioCache(url, extFile: "pdf", ttl: cacheDuration);
print('File downloaded and cached at: ${file.path}');
} catch (e) {
print('Error: $e');
}
}