flutter_future_progress_dialog 1.0.0 copy "flutter_future_progress_dialog: ^1.0.0" to clipboard
flutter_future_progress_dialog: ^1.0.0 copied to clipboard

outdated

Allows to display progress dialog while the Future function is evaluated.

flutter_future_progress_dialog #

Pub Version GitHub

Show progress dialog with animation while waiting for Future completion and then return the result of that Future.

Features #

Iphone 14

Getting started #

  • install the library
flutter pub add flutter_future_progress_dialog
  • import the library
import 'package:flutter_future_progress_dialog/flutter_future_progress_dialog.dart';

Usage #

Working example can be found in /example directory.

Here is a short example of `showProgressDialog`` usage.

Call the showProgressDialog inside your function. Pass context and future arguments. Then handle result.


Future<String> myFuture() async {
  await Future.delayed(const Duration(seconds: 2));
  return 'my string';
}

Future<void> yourFunction(BuildContext context) async {
  final result = await showProgressDialog(
    context: context,
    future: () => myFuture(),
  );
  if (!mounted) {
    return;
  }
  if (result.isError) {
    showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
            content: Text(
              '${result.requireError}',
              textAlign: TextAlign.center,
            ),
            actions: [
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop();
                },
                child: const Text(
                  'OK',
                ),
              ),
            ],
          );
      },
    );
    return;
  }
  const result = result.requireValue; // result variable would hold the 'my string' value here 
}

Optionally you can pass a builder to have a custom progress dialog

Future<void> buttonCallback({
  required BuildContext context,
}) async {
  final result = await showProgressDialog(
    future: () => myLongRunningTask(),
    context: context,
    builder: (context) => AlertDialog(
      content: Text('I am loading now'),
    ),
  );
  return result!;
}
4
likes
0
points
357
downloads

Publisher

verified publishernerdy.pro

Weekly Downloads

Allows to display progress dialog while the Future function is evaluated.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_future_progress_dialog