cross_cache 1.0.2 copy "cross_cache: ^1.0.2" to clipboard
cross_cache: ^1.0.2 copied to clipboard

Cross-platform cache manager for Flutter using IndexedDB for web, file system for mobile and desktop, and Dio for network requests. #cache #indexeddb #dio

example/README.md

import 'package:flutter/material.dart';
import 'package:cross_cache/cross_cache.dart';

class MyWidget extends StatefulWidget {
  @override
  _MyWidgetState createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  final _cache = CrossCache(); // Create an instance

  @override
  void dispose() {
    _cache.dispose(); // Dispose the cache
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Image(
      image: CachedNetworkImage(
        'https://example.com/image.jpg',
        _cache, // Pass the cache instance
        headers: {'Authorization': 'Bearer YOUR_TOKEN'}, // Optional headers
      ),
      loadingBuilder: (context, child, loadingProgress) {
        if (loadingProgress == null) return child;
        return Center(
          child: CircularProgressIndicator(
            value: loadingProgress.expectedTotalBytes != null
                ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
                : null,
          ),
        );
      },
      errorBuilder: (context, error, stackTrace) => Icon(Icons.error),
    );
  }
}

3
likes
160
points
6.38k
downloads

Publisher

verified publisherflyer.chat

Weekly Downloads

Cross-platform cache manager for Flutter using IndexedDB for web, file system for mobile and desktop, and Dio for network requests. #cache #indexeddb #dio

Homepage
Repository (GitHub)
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

cross_file, crypto, dio, flutter, idb_shim, path_provider

More

Packages that depend on cross_cache