flutter_cache_manager 0.3.0-beta.2+1 copy "flutter_cache_manager: ^0.3.0-beta.2+1" to clipboard
flutter_cache_manager: ^0.3.0-beta.2+1 copied to clipboard

outdated

Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  FileInfo fileInfo;

  _downloadFile() {
    var url =
        'https://cdn2.online-convert.com/example-file/raster%20image/png/example_small.png';

    DefaultCacheManager().getFile(url).listen((f) {
      setState(() {
        fileInfo = f;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    var path = "N/A";
    if (fileInfo?.file != null) {
      path = fileInfo.file.path;
    }
    var from = "N/A";
    if (fileInfo != null) {
      from = fileInfo.source.toString();
    }
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Local filePath:',
            ),
            Text(
              path,
            ),
            Text(
              'From: $from',
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _downloadFile,
        tooltip: 'Download',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1.84k
likes
0
points
2.35M
downloads

Publisher

verified publisherbaseflow.com

Weekly Downloads

Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http, path, path_provider, sqflite, synchronized, uuid

More

Packages that depend on flutter_cache_manager