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

A stunning, fully dynamic, and customizable dialog package for Flutter apps, natively supporting Android and iOS with professional-level UI alerts.

Dialog Builder 🚀 #

Pub Version License Platform

A stunning, professional, and easy-to-use standard dialog package for Flutter apps, bringing beautiful UI alerts straight out of the box with zero boilerplate.

Say goodbye to manual dialog widgets! Create beautiful Success, Error, Warning, Info, Confirmation, and Loading states.


✨ Features #

  • Beautiful Default Configurations: Instantly deploy Success, Error, Warning, Info, Confirmation, and Loading dialogs.
  • Basic Customization: Easily override default colors and icons.
  • Material 3 Theme Aware: Automatically and seamlessly inherits ThemeData to look native in standard or dark modes.
  • Responsive Layouts: Designed professionally with carefully tested standard margins, paddings, and proportions.
  • Zero Dependencies: Pure Flutter code avoiding 3rd-party baggage and ensuring high performance.

💻 Installation #

  1. Add the package to your project's pubspec.yaml:
dependencies:
  dialog_builder: ^1.0.0
  1. Get the packages via terminal:
flutter pub get
  1. Import the file where you need to use it:
import 'package:dialog_builder/dialog_builder.dart';

🛠️ Usage Examples #

Below are a few ways you can construct beautiful standard dialogs using DialogBuilder:

1️⃣ Simple Success Dialog (Default Layouts) #

Just set the type and provide text. The DialogBuilder automatically populates the default success color (green) and an appropriate checkmark.

ElevatedButton(
  onPressed: () {
    DialogBuilder.instance.show(
      context: context,
      type: DialogType.success,
      config: const DialogConfig(
        title: 'Payment Successful!',
        description: 'Your transaction was completed successfully.',
        primaryButtonText: 'Done',
      ),
    );
  },
  child: const Text('Show Success Dialog'),
);

2️⃣ Customized Error Dialog #

You can control the exact look of a dialog by overriding customColor or customIcon.

DialogBuilder.instance.show(
  context: context,
  type: DialogType.error,
  config: const DialogConfig(
    title: 'Authentication Failed',
    description: 'The PIN you entered was incorrect.',
    primaryButtonText: 'Try Again',
    secondaryButtonText: 'Forgot PIN?',
    
    // Customizations
    customColor: Colors.purple, // Base color will be purple 
    customIcon: Icons.lock_clock, // Custom icon overriding the default Error icon
  ),
);

3️⃣ Managing Background Tasks with "Loading" #

The loading dialog prevents users from tapping the background while an asynchronous task runs, and provides a way to gracefully hide the dialog once finished.

ElevatedButton(
  onPressed: () async {
    // 1. Show the Loading Dialog
    DialogBuilder.instance.show(
      context: context,
      type: DialogType.loading,
      config: const DialogConfig(
        title: 'Processing Request...',
        description: 'Please wait a moment',
        isDismissible: false, // Prevents closing by tapping outside
        customColor: Colors.deepPurple,
      ),
    );
    
    // 2. Simulate Network Request/Heavy task
    await Future.delayed(const Duration(seconds: 2));
    
    // 3. Hide the Loading Dialog
    if (context.mounted) {
      DialogBuilder.instance.hide(context);
    }
  },
  child: const Text('Simulate Network Request'),
);

⚙️ Handling Button Actions #

You can execute complex logic using onPrimaryAction and onSecondaryAction. The actions automatically run without immediately dismissing the dialog, so be sure to call Navigator.of(context).pop() (or your router's pop equivalent) inside your custom function!

DialogBuilder.instance.show(
  context: context,
  type: DialogType.warning,
  config: DialogConfig(
    title: 'Delete Account?',
    description: 'This action cannot be undone.',
    primaryButtonText: 'Yes, Delete',
    secondaryButtonText: 'Cancel',
    onPrimaryAction: () async {
      Navigator.of(context).pop(); // Close the dialog first
      // Execute your hard logic
      await deleteUserAccount(); 
    },
    // Optional: onSecondaryAction will also implicitly use Navigator.pop by default if left null.
  ),
);

🚀 Issues and Contributions #

If you find a bug or have an awesome idea for a new feature, please open an issue or submit a pull request!

0
likes
160
points
20
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A stunning, fully dynamic, and customizable dialog package for Flutter apps, natively supporting Android and iOS with professional-level UI alerts.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, google_fonts, iconly

More

Packages that depend on dialog_builder