custom_file_downloader 0.0.6 copy "custom_file_downloader: ^0.0.6" to clipboard
custom_file_downloader: ^0.0.6 copied to clipboard

A Flutter plugin to download files with progress tracking and local notifications on Android and iOS.

example/lib/main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await CustomFileDownloader.initialize();
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Plugin example app')),
        body: Align(
          alignment: Alignment.topCenter,
          child: Column(
            children: [
              SizedBox(height: 20,),
              ButtonText(
                title: 'Download Video',
                onPressed: () {
                  CustomFileDownloader.downloadFile(
                    url:
                        'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
                    onCompleted: (path) {
                      // CustomFileDownloader.openApk();
                      print('Download complete: $path');
                    },
                    onError: (error) {
                      print('Download error: $error');
                    },
                  );
                },
              ),
              ButtonText(
                title: 'Download APK',
                onPressed: ()async {

                  CustomFileDownloader.downloadFile(
                     url:
                     'https://tigratem.com//apk//app-release.apk',
                     onCompleted: (path) {
                       print('Download complete: $path');
                     },
                     onError: (error) {
                       print('Download error: $error');
                     },
                   );
                },
              ),
              ButtonText(
                title: 'Download PDF',
                onPressed: () {
                  CustomFileDownloader.downloadFile(
                    url:
                        'https://morth.nic.in/sites/default/files/dd12-13_0.pdf',
                    onCompleted: (path) {
                      print('Download complete: $path');
                    },
                    onError: (error) {
                      print('Download error: $error');
                    },
                  );
                },
              ),
              ButtonText(
                title: 'Download Image',
                onPressed: () {
                  CustomFileDownloader.downloadFile(
                    url:
                        // 'https://www.instagram.com/reel/DLNg3aFNPAM/?utm_source=ig_web_copy_link',
                        'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS-xnGLZJFli6FRyXSlm8-QnpJb9hh30HffEA&s',
                    onCompleted: (path) {
                      print('Download complete: $path');
                    },
                    onError: (error) {
                      print('Download error: $error');
                    },
                  );
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

class ButtonText extends StatelessWidget {
  final String title;
  final Function() onPressed;

  const ButtonText({super.key, required this.title, required this.onPressed});

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(onPressed: onPressed, child: Text(title));
  }
}
0
likes
150
points
33
downloads

Publisher

verified publishermanishtalreja.in

Weekly Downloads

A Flutter plugin to download files with progress tracking and local notifications on Android and iOS.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, flutter_local_notifications, http, mime, path_provider, plugin_platform_interface

More

Packages that depend on custom_file_downloader

Packages that implement custom_file_downloader