network_file_cached 0.0.2 copy "network_file_cached: ^0.0.2" to clipboard
network_file_cached: ^0.0.2 copied to clipboard

outdated

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

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
import 'package:network_file_cached/network_file_cached.dart';

void main() async {
  await NetworkFileCached.init(
    expired: const Duration(minutes: 5),
  );
  runApp(
    const MaterialApp(
      home: FileCache(),
    ),
  );
}

class FileCache extends StatefulWidget {
  const FileCache({super.key});

  @override
  State<FileCache> createState() => _FileCacheState();
}

class _FileCacheState extends State<FileCache> {
  String uri = 'https://s.id/1zvyC';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example apps'),
        ),
        body: FutureBuilder(
            future: NetworkFileCached.downloadFile(uri),
            builder: (context, snapshoot) {
              if (snapshoot.hasData) {
                return PDFView(
                  pdfData: snapshoot.data?.readAsBytesSync(),
                );
              }
              if (snapshoot.hasError) {
                return Text(snapshoot.error.toString());
              }
              return const Text('LOADING...');
            }));
  }
}
4
likes
0
points
249
downloads

Publisher

verified publisherdigitalservice.id

Weekly Downloads

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, hive, mime, path, path_provider

More

Packages that depend on network_file_cached