AlertDialog constructor

const AlertDialog({
  1. Key? key,
  2. Widget? leading,
  3. Widget? title,
  4. Widget? content,
  5. List<Widget>? actions,
  6. Widget? trailing,
  7. double? surfaceBlur,
  8. double? surfaceOpacity,
  9. Color? barrierColor,
  10. EdgeInsetsGeometry? padding,
})

Creates an AlertDialog.

All parameters are optional, allowing for flexible dialog configurations from simple text alerts to complex confirmation interfaces.

Parameters:

  • leading (Widget?, optional): Icon or graphic at dialog start
  • title (Widget?, optional): Primary dialog heading
  • content (Widget?, optional): Detailed description or message
  • actions (List
  • trailing (Widget?, optional): Additional controls at dialog end
  • surfaceBlur (double?, optional): Backdrop blur intensity
  • surfaceOpacity (double?, optional): Backdrop opacity level
  • barrierColor (Color?, optional): Backdrop overlay color
  • padding (EdgeInsetsGeometry?, optional): Internal content padding

Example:

AlertDialog(
  title: Text('Confirm Action'),
  content: Text('This action cannot be undone.'),
  actions: [
    TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')),
    ElevatedButton(onPressed: _confirm, child: Text('Confirm')),
  ],
);

Implementation

const AlertDialog({
  super.key,
  this.leading,
  this.title,
  this.content,
  this.actions,
  this.trailing,
  this.surfaceBlur,
  this.surfaceOpacity,
  this.barrierColor,
  this.padding,
});