Version 2.0.0 Flutter Dart MIT License pub.dev

Beautiful Alert Dialogs for Flutter

KAlertFlutter is a modern, customizable, Material-style alert dialog library for Flutter. Build success, error, warning, info, question, progress, input, custom image, URL image, and custom view dialogs with clean APIs.

Install from pub.dev
dependencies:
  kalertflutter: ^2.0.0
Features

Professional Flutter dialogs for real apps.

KAlertFlutter includes modern presets, dark mode support, input validation, custom widgets, progress dialogs, image dialogs, button styling, callbacks, and backward compatibility with the old API.

Multiple dialog types

Create normal, success, error, warning, info, question, progress, input, custom image, URL image, and custom view dialogs.

Dark mode friendly

KAlertFlutter automatically respects your Flutter app theme and adapts to light or dark mode.

Advanced customization

Control title, content, icons, colors, radius, elevation, dim amount, button styling, and text weights.

Input validation

Build input dialogs with initial value, max length, keyboard type, validation, and confirm callbacks.

Custom widget support

Place any Flutter widget inside a dialog using KAlertDialog.customView().

🖼

Image dialogs

Show custom images, URL images, circle images, big images, placeholders, and error widgets.

Progress dialogs

Show loading and processing states with non-dismissible progress dialogs.

Clean callbacks

Use onShow, onDismiss, onConfirm, onCancel, and input confirm callbacks.

Backward compatible

Old KAlert.show(), KAlert.confirm(), and KAlert.prompt() APIs still work with the new UI.

Latest Release

Version 2.0.0

A major feature upgrade that brings KAlertFlutter closer to the native Android KAlertDialog library.

2.0.0

Major feature upgrade release

  • Added new modern KAlertDialog API.
  • Added success, error, warning, info and question dialogs.
  • Added progress/loading dialog support.
  • Added input validation and max length support.
  • Added custom Flutter widget support.
  • Added custom image and URL image dialogs.
  • Added big and circle URL image modes.
  • Added style presets: classic, modern, minimal and rounded.
  • Added custom radius, elevation and dim amount.
  • Added title, content and button font weight support.
  • Added confirm and cancel button customization.
  • Added show, dismiss, confirm and cancel callbacks.
  • Added dark mode friendly UI.
  • Added smooth fade and scale animations.
  • Kept old KAlert.show(), confirm() and prompt() APIs.
  • Fixed generic result type and input controller lifecycle issues.
Setup

Install KAlertFlutter

Add KAlertFlutter to your Flutter project and start creating beautiful dialogs.

Step 1: Add dependency

pubspec.yaml
dependencies:
  kalertflutter: ^2.0.0

Step 2: Import package

Dart
import 'package:kalertflutter/kalertflutter.dart';

Run Flutter pub get

After adding the dependency, run this command:

Terminal
flutter pub get
Documentation

Usage examples

Copy-paste ready examples for common KAlertFlutter use cases.

Success dialog

Use this after saving data, completing a task, or confirming a successful action.

Dart
KAlertDialog.success(
  context: context,
  title: 'Success',
  content: 'Your changes were saved successfully.',
  confirmText: 'Done',
);

Error dialog

Use this for API failures, network issues, validation errors, or unexpected problems.

Dart
KAlertDialog.error(
  context: context,
  title: 'Oops...',
  content: 'Something went wrong. Please try again.',
  confirmText: 'Try Again',
);

Warning confirm / cancel flow

Ask users before destructive actions and handle confirm or cancel results.

Dart
final result = await KAlertDialog.warning(
  context: context,
  title: 'Delete this file?',
  content: 'This action cannot be undone.',
  confirmText: 'Delete',
  cancelText: 'Cancel',
);

if (result?.confirmed == true) {
  KAlertDialog.success(
    context: context,
    title: 'Deleted',
    content: 'The file has been deleted successfully.',
  );
}

Question dialog

Use this when you need a yes/no response.

Dart
final result = await KAlertDialog.question(
  context: context,
  title: 'Continue?',
  content: 'Do you want to continue with this action?',
  confirmText: 'Yes',
  cancelText: 'No',
);

if (result?.confirmed == true) {
  debugPrint('User selected yes');
}

Progress dialog

Show loading or processing states with non-dismissible progress dialogs.

Dart
KAlertDialog.progress(
  context: context,
  title: 'Processing',
  content: 'Please wait while we prepare your request.',
  barrierDismissible: false,
);

await Future.delayed(const Duration(seconds: 3));

if (context.mounted) {
  Navigator.of(context).pop();

  KAlertDialog.success(
    context: context,
    title: 'Completed',
    content: 'Your request has been completed successfully.',
  );
}

Input dialog with validation

Validate input before allowing the user to continue.

Dart
final result = await KAlertDialog.input(
  context: context,
  title: 'Create Project',
  content: 'Enter a project name with at least 3 characters.',
  hintText: 'Project name',
  initialValue: 'KAlertFlutter',
  maxLength: 30,
  validator: (input) {
    if (input.trim().length < 3) {
      return 'Project name must be at least 3 characters';
    }
    return null;
  },
);

if (result?.confirmed == true) {
  debugPrint('Input value: ${result?.value}');
}

Custom view dialog

Place any Flutter widget inside the dialog.

Dart
final controller = TextEditingController();

KAlertDialog.customView(
  context: context,
  title: 'Custom View',
  content: 'This dialog uses your own custom Flutter widget.',
  showCancelButton: true,
  confirmText: 'Save',
  cancelText: 'Cancel',
  child: Column(
    mainAxisSize: MainAxisSize.min,
    children: [
      TextField(
        controller: controller,
        decoration: const InputDecoration(
          labelText: 'Project name',
          border: OutlineInputBorder(),
        ),
      ),
    ],
  ),
  onConfirm: () {
    debugPrint('Saved: ${controller.text}');
  },
);

URL image dialog

Show big or circle URL images with fallback support.

Dart
KAlertDialog.urlImage(
  context: context,
  title: 'Big URL Image',
  content: 'This image is loaded from a URL.',
  imageUrl: 'https://example.com/image.png',
  imageType: KAlertImageType.big,
  confirmText: 'Close',
);

Custom appearance

Customize dialog radius, elevation, dim amount, colors, and text weights.

Dart
KAlertDialog.show(
  context: context,
  title: 'Custom Appearance',
  content: 'This dialog has custom radius, elevation and dim amount.',
  type: KAlertType.normal,
  style: KAlertStyle.modern,
  cornerRadius: 30,
  elevation: 20,
  dimAmount: 0.60,
  titleFontWeight: FontWeight.w900,
  contentFontWeight: FontWeight.w500,
  confirmText: 'Looks Good',
);

Callbacks

Use callbacks for dialog lifecycle and button events.

Dart
KAlertDialog.show(
  context: context,
  title: 'Callbacks',
  content: 'This dialog shows callback APIs.',
  type: KAlertType.normal,
  showCancelButton: true,
  confirmText: 'Confirm',
  cancelText: 'Cancel',
  onShow: () {
    debugPrint('Dialog shown');
  },
  onDismiss: () {
    debugPrint('Dialog dismissed');
  },
  onConfirm: () {
    debugPrint('Confirmed');
  },
  onCancel: () {
    debugPrint('Cancelled');
  },
);

Backward compatible old API

Old APIs are still supported and now use the new modern UI internally.

Dart
KAlert.show(
  context,
  title: 'Success',
  message: 'Saved successfully!',
  type: KAlertType.success,
);

bool? result = await KAlert.confirm(
  context,
  title: 'Delete file?',
  message: 'This action cannot be undone',
);

String? value = await KAlert.prompt(
  context,
  title: 'Enter your name',
);
Native Android Version

Building native Android apps in Java?

Use the original native Android Java library, KAlertDialog. It provides the same modern dialog experience for Android Java apps with success, error, warning, progress, input, URL image, custom image, and custom view dialogs.

Library Platform Package
KAlertFlutter Flutter / Dart pub.dev
KAlertDialog Native Android Java Maven Central
Use case Modern dialogs Open source
KAlertDialog Android dependency
implementation 'io.github.tutorialsandroid:kalertdialog:21.0.0'
implementation 'io.github.tutorialsandroid:progressx:7.0.5'
API Summary

Quick API reference

The most-used KAlertFlutter types and methods.

Dialog types

KAlertType.normal
KAlertType.success
KAlertType.error
KAlertType.warning
KAlertType.info
KAlertType.question
KAlertType.progress
KAlertType.input
KAlertType.customImage
KAlertType.urlImage
KAlertType.customView

Style presets

KAlertStyle.classic
KAlertStyle.modern
KAlertStyle.minimal
KAlertStyle.rounded

Image types

KAlertImageType.big
KAlertImageType.circle

Main methods

KAlertDialog.show()
KAlertDialog.success()
KAlertDialog.error()
KAlertDialog.warning()
KAlertDialog.info()
KAlertDialog.question()
KAlertDialog.progress()
KAlertDialog.input()
KAlertDialog.customView()
KAlertDialog.customImage()
KAlertDialog.urlImage()

Appearance options

cornerRadius: 30
elevation: 20
dimAmount: 0.60
maxWidth: 360
backgroundColor: Colors.white
titleColor: Colors.black
contentColor: Colors.grey
iconColor: Colors.green

Button options

confirmText: 'OK'
cancelText: 'Cancel'
showConfirmButton: true
showCancelButton: true
confirmButtonColor: Colors.green
cancelButtonColor: Colors.grey
confirmButtonAllCaps: false
cancelButtonAllCaps: false

Input options

hintText: 'Project name'
initialValue: 'KAlertFlutter'
maxLength: 30
keyboardType: TextInputType.text
validator: (input) { return null; }
onInputConfirm: (input) { }

Backward compatible

KAlert.show()
KAlert.confirm()
KAlert.prompt()
FAQ

Common questions

Quick answers for setup and common usage.

What is KAlertFlutter?

KAlertFlutter is a modern Material-style alert dialog package for Flutter. It supports success, error, warning, info, question, progress, input, custom image, URL image, and custom view dialogs.

How do I install KAlertFlutter?

Add kalertflutter to your pubspec.yaml file and run flutter pub get.

Does KAlertFlutter support dark mode?

Yes. KAlertFlutter automatically respects your Flutter app theme and adapts to light or dark mode.

Can I use custom Flutter widgets inside the dialog?

Yes. Use KAlertDialog.customView() and pass any Flutter widget as the child.

Does it support input validation?

Yes. KAlertDialog.input() supports validator callbacks, max length, initial value, keyboard type, and input confirm callbacks.

Is there a native Android Java version?

Yes. The native Android Java version is KAlertDialog, available on GitHub and Maven Central.

Open Source

Build beautiful Flutter dialogs faster with KAlertFlutter.

Install the latest version, explore the example app, and support the project on GitHub and pub.dev.

Copied to clipboard