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

discontinued

Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. It has an extra method to check if file exists in cache without loading it to memory.

example/lib/main.dart

import 'package:baseflow_plugin_template/baseflow_plugin_template.dart';
import 'package:example/plugin_example/download_page.dart';
import 'package:example/plugin_example/floating_action_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_cache_manager_extended/flutter_cache_manager_extended.dart';

void main() {
  runApp(BaseflowPluginExample(
    pluginName: 'Flutter Cache Manager',
    githubURL: 'https://github.com/Baseflow/flutter_cache_manager',
    pubDevURL: 'https://pub.dev/packages/flutter_cache_manager',
    pages: [CacheManagerPage.createPage()],
  ));
}

const url = 'https://blurha.sh/assets/images/img1.jpg';

/// Example [Widget] showing the functionalities of flutter_cache_manager
class CacheManagerPage extends StatefulWidget {
  static ExamplePage createPage() {
    return ExamplePage(Icons.save_alt, (context) => CacheManagerPage());
  }

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

class _CacheManagerPageState extends State<CacheManagerPage> {
  Stream<FileResponse> fileStream;

  void _downloadFile() {
    setState(() {
      fileStream = DefaultCacheManager().getFileStream(url, withProgress: true);
    });
  }

  @override
  Widget build(BuildContext context) {
    if (fileStream == null) {
      return Scaffold(
        appBar: null,
        body: const ListTile(
            title: Text('Tap the floating action button to download.')),
        floatingActionButton: Fab(
          downloadFile: _downloadFile,
        ),
      );
    }
    return DownloadPage(
      fileStream: fileStream,
      downloadFile: _downloadFile,
      clearCache: _clearCache,
    );
  }

  void _clearCache() {
    DefaultCacheManager().emptyCache();
    setState(() {
      fileStream = null;
    });
  }
}
0
likes
30
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. It has an extra method to check if file exists in cache without loading it to memory.

Homepage

License

MIT (license)

Dependencies

clock, file, flutter, http, image, path, path_provider, pedantic, rxdart, sqflite, uuid

More

Packages that depend on flutter_cache_manager_extended