network_file_cacher 1.1.0 copy "network_file_cacher: ^1.1.0" to clipboard
network_file_cacher: ^1.1.0 copied to clipboard

A flutter library to download and cache files in the cache directory of the app.

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:network_file_cacher/network_file_cacher.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await NetworkFileCacher.init(expired: const Duration(hours: 1));
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Network File Cached Example')),
        body: Center(
          child: FutureBuilder<File>(
            future: NetworkFileCacher.downloadFile(
              'https://picsum.photos/200/300',
            ),
            builder: (context, snapshot) {
              if (snapshot.connectionState == ConnectionState.waiting) {
                return const CircularProgressIndicator();
              }
              if (snapshot.hasError) {
                return Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Text('Error: ${snapshot.error}'),
                );
              }
              if (snapshot.hasData) {
                return Image.file(snapshot.data!);
              }
              return const Text('No Data');
            },
          ),
        ),
      ),
    );
  }
}
2
likes
160
points
74
downloads

Documentation

API reference

Publisher

verified publisherdevlab.my.id

Weekly Downloads

A flutter library to download and cache files in the cache directory of the app.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, dio, flutter, hive, hive_flutter, mime, path, path_provider

More

Packages that depend on network_file_cacher