adaptive_progress_dialog 1.0.1 copy "adaptive_progress_dialog: ^1.0.1" to clipboard
adaptive_progress_dialog: ^1.0.1 copied to clipboard

outdated

A Flutter package providing an adaptive progress dialog. Using this package you can perform async operation while displaying adaptive progress dialog and get the result of the operation. The AdaptiveP [...]

example/lib/main.dart

import 'package:adaptive_progress_dialog/adaptive_progress_dialog.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Adaptive Progress Dialog Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String? dialogData;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Demo Home Page'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (dialogData != null)
              Text(
                dialogData!,
                style: const TextStyle(fontSize: 26),
              ),
            const SizedBox(height: 64),
            ElevatedButton(
              onPressed: () async {
                final dialog = AdaptiveProgressDialog<String>(
                  title: 'Progress Dialog',
                  content: 'Do you want to perform async operation?',
                  confirmationButtonLabel: 'Yes',
                  cancelButtonLabel: 'No, close',
                  confirmButtonCallback: () async {
                    await Future.delayed(const Duration(seconds: 5));
                    return "Dialog Result Data";
                  },
                  adaptiveProgressDialogStyle: AdaptiveProgressDialogStyle(
                    confirmButtonTextStyle: const TextStyle(color: Colors.red),
                  ),
                );

                final adaptiveProgressDialogResult = await dialog.show(context);

                switch (adaptiveProgressDialogResult.status) {
                  case DialogStatus.success:
                    setState(() {
                      dialogData = adaptiveProgressDialogResult.data;
                    });
                    break;
                  case DialogStatus.canceled:
                    print("Dialog canceled by pressing on cancel button");
                    break;
                  case DialogStatus.error:
                    print(
                        "Dialog error: ${adaptiveProgressDialogResult.error}");
                    break;
                  case DialogStatus.closed:
                    print("Dialog canceled by pressing outside dialog");
                    break;
                }
              },
              child: const Text("Show adaptive dialog"),
            )
          ],
        ),
      ),
    );
  }
}
15
likes
0
points
69
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package providing an adaptive progress dialog. Using this package you can perform async operation while displaying adaptive progress dialog and get the result of the operation. The AdaptiveProgressDialog widget is generic and takes a type parameter T which is used to represent the data that can be returned from the async operation performed by dialog. The data is returned via the AdaptiveProgressDialogResult class.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on adaptive_progress_dialog