custom_file_downloader 0.0.2 copy "custom_file_downloader: ^0.0.2" to clipboard
custom_file_downloader: ^0.0.2 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 FileDownloadService.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: () {
                  FileDownloadService.downloadFile(
                    url:
                        'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
                    onCompleted: (path) {
                      print('Download complete: $path');
                    },
                    onError: (error) {
                      print('Download error: $error');
                    },
                  );
                },
              ),
              ButtonText(
                title: 'Download APK',
                onPressed: () {
                  FileDownloadService.downloadFile(
                    url:
                        'https://sample-files-online.com/samples/countdownload/905',
                    onCompleted: (path) {
                      print('Download complete: $path');
                    },
                    onError: (error) {
                      print('Download error: $error');
                    },
                  );
                },
              ),
              ButtonText(
                title: 'Download PDF',
                onPressed: () {
                  FileDownloadService.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: () {
                  FileDownloadService.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
0
points
22
downloads

Publisher

verified publishermanishtalreja.in

Weekly Downloads

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

Homepage

License

unknown (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