ConfirmationDialog class

A customizable confirmation dialog widget with icon, title, content, and action buttons.

This dialog provides a standard way to request user confirmation before performing an action. It supports custom icons, titles, content, and button labels with customizable colors.

Usage:

showDialog(
  context: context,
  builder: (context) => ConfirmationDialog(
    title: 'Delete Item',
    content: 'Are you sure you want to delete this item?',
    onConfirm: () {
      // Handle confirmation
    },
    onCancel: () {
      // Handle cancellation
    },
  ),
)
Inheritance

Constructors

ConfirmationDialog({Key? key, required String title, String? content, Widget? child, required VoidCallback onConfirm, VoidCallback? onCancel, String? okText, Color? okColor, String? cancelText, Color? cancelColor, IconData? icon})
Creates a ConfirmationDialog widget.
const

Properties

cancelColor Color?
The color for the cancel button text and icon.
final
cancelText String?
The text label for the cancel button.
final
child Widget?
Custom widget to display in the dialog body.
final
content String?
The content text displayed in the body of the dialog.
final
hashCode int
The hash code for this object.
no setterinherited
icon IconData?
The icon to display at the top of the dialog.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
okColor Color?
The color for the confirm/OK button text and icon.
final
okText String?
The text label for the confirm/OK button.
final
onCancel VoidCallback?
Optional callback function executed when the cancel button is pressed.
final
onConfirm VoidCallback
Callback function executed when the confirm button is pressed.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
title String
The title text displayed at the top of the dialog.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

defaultCancelText String Function()
Function that returns the default text for the cancel button.
getter/setter pair
defaultOkText String Function()
Function that returns the default text for the OK/confirm button.
getter/setter pair