flowder_v2 1.0.1 copy "flowder_v2: ^1.0.1" to clipboard
flowder_v2: ^1.0.1 copied to clipboard

Persistent file downloader manager, start, pause, resume, cancel your download.

example/lib/main.dart

import 'dart:io';

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

import 'package:flowder_v2/flowder.dart';
import 'package:path_provider/path_provider.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late DownloaderUtils options;
  late DownloaderCore core;
  late final String path;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    _setPath();
    if (!mounted) return;
  }

  void _setPath() async {
    path = (await getExternalStorageDirectory())!.path;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('TERI TERI'),
            Text('Audio'),
            ElevatedButton(
              onPressed: () async {
                options = DownloaderUtils(
                  progressCallback: (current, total) {
                    final progress = (current / total) * 100;
                    print('Downloading: $progress');
                  },
                  file: File('$path/200MB.zip'),
                  progress: ProgressImplementation(),
                  onDone: () => print('COMPLETE'),
                  deleteOnCancel: true,
                );
                core = await Flowder.download(
                    'http://ipv4.download.thinkbroadband.com/200MB.zip', options);
              },
              child: Text('DOWNLOAD'),
            ),
            ElevatedButton(
              onPressed: () async => core.resume(),
              child: Text('RESUME'),
            ),
            ElevatedButton(
              onPressed: () async => core.cancel(),
              child: Text('CANCEL'),
            ),
            ElevatedButton(
              onPressed: () async => core.pause(),
              child: Text('PAUSE'),
            ),
          ],
        ),
      ),
    );
  }
}
9
likes
140
pub points
77%
popularity

Publisher

unverified uploader

Persistent file downloader manager, start, pause, resume, cancel your download.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter, flutter_web_plugins

More

Packages that depend on flowder_v2