flutter_progress
Highly customizable and light weight progress library including dynamic updates
Getting Started
Adding the package
dependencies: flutter_progress: ^1.0.0
Examples
How to use
Add import
import 'package:flutter_progress/flutter_progress.dart';
Show dialog and assign it a global key to update it later.
All properties except the message are optional.
var dialogKey = GlobalKey<ProgressDialogState>(); showDialog( context: context, builder: (context) => ProgressDialog( key: dialogKey, config: const Config( message: "Starting download", maxProgress: 100, progressValueColor: const Color(0xff3550B4), progressBgColor: Colors.white70, progressType: ProgressType.valuable, ), ), );
Dynamically update all available properties with the dialog key:
ProgressDialog.update(dialogKey, config: Config( message: "Downloading data", progress: i, ));
Dialog can be closed with Navigator.pop(context)
or via the dialog key:
ProgressDialog.safeClose(dialogKey);
Progress Completed Type
Use this to specify fields to be used when the progress is finished.
completed: ProgressCompleted( message: "Finished downloading!", body: Image.asset("assets/completed_check.png", width: ProgressDialog.loaderSize.width), ),
Example DIO usage
var dialogKey = GlobalKey<ProgressDialogState>(); showDialog( context: context, builder: (context) => ProgressDialog( key: dialogKey, config: const Config(message: "Starting download", completed: ProgressCompleted(message: "Download finished")), ), ); try { await Dio().download("http://ipv4.download.thinkbroadband.com/5MB.zip", "test.zip", onReceiveProgress: (count, total) { ProgressDialog.update( dialogKey, config: Config(message: "Downloading file...", progress: count, maxProgress: total), ); }); } catch (e) { ProgressDialog.update(dialogKey, config: Config(message: "Download failed: $e")); } finally { await Future.delayed(const Duration(seconds: 3)); ProgressDialog.safeClose(dialogKey); }
Download and contribute to flutter progress library source code on GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.