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

A downloader that supports continuing downloads

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ContinueDownloader downloader = ContinueDownloader();

  int receivedBytes = 0;
  int totalBytes = 0;
  var url = "";
  var savePath = "";
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('ContinueDownloader')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  downloader.startDownload(
                      url: url,
                      savePath: savePath,
                      process: (c, t) {
                        receivedBytes = c;
                        totalBytes = t;
                        setState(() {});
                      });
                },
                child: const Text('start download'),
              ),
              const SizedBox(height: 20),
              Text(
                'now: $receivedBytes / $totalBytes bytes',
                style: const TextStyle(fontSize: 18),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () {
                  downloader.close();
                },
                child: const Text('pause'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

A downloader that supports continuing downloads

Repository

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, http, plugin_platform_interface

More

Packages that depend on continue_downloader