fast_download_manager 1.0.0
fast_download_manager: ^1.0.0 copied to clipboard
A lightweight Flutter package for downloading files with real-time progress tracking.
import 'package:fast_download_manager/fast_download_manager.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: DownloadScreen(),
);
}
}
class DownloadScreen extends StatefulWidget {
const DownloadScreen({super.key});
@override
State<DownloadScreen> createState() => _DownloadScreenState();
}
class _DownloadScreenState extends State<DownloadScreen> {
double progress = 0;
Future<void> downloadFile() async {
final dir = await getApplicationDocumentsDirectory();
await FastDownloader.download(
url:
'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
savePath: '${dir.path}/sample.pdf',
onProgress: (p) {
setState(() {
progress = p;
});
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Fast Downloader'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LinearProgressIndicator(value: progress),
const SizedBox(height: 20),
Text("${(progress * 100).toStringAsFixed(0)}%"),
const SizedBox(height: 20),
ElevatedButton(
onPressed: downloadFile,
child: const Text("Download"),
),
],
),
),
);
}
}