flutter_progress

Pub Version Last commit Pull Requests Code size

Highly customizable and light weight progress library including dynamic updates

Examples

Normal Progress Valuable Progress
Normal Progress Valuable Progress
Custom Body Progress Custom Progress
Custom Body Progress Custom Progress

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 Progress
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);
}

Libraries

flutter_progress