Skip to main content

showChromiaDialog

Shows a customizable dialog.

Basic Usage

await showChromiaDialog(
  context: context,
  title: 'Confirm Action',
  content: 'Are you sure you want to continue?',
  actions: [
    ChromiaDialogAction(
      label: 'Cancel',
      onPressed: () => Navigator.pop(context),
    ),
    ChromiaDialogAction(
      label: 'Confirm',
      isPrimary: true,
      onPressed: () => Navigator.pop(context, true),
    ),
  ],
);

Parameters

context
BuildContext
required
Build context
title
String?
Title text
titleWidget
Widget?
Custom title widget (overrides title)
content
String?
Content text
contentWidget
Widget?
Custom content widget (overrides content)
actions
List<ChromiaDialogAction>?
Action buttons
barrierDismissible
bool
default:"true"
Whether the dialog can be dismissed by tapping outside
barrierColor
Color?
Color of the barrier (overlay)
width
double?
Width of the dialog
contentPadding
EdgeInsetsGeometry?
Padding for content area

ChromiaDialog

The dialog widget itself (usually used through showChromiaDialog).

Parameters

title
String?
Title text
titleWidget
Widget?
Custom title widget
content
String?
Content text
contentWidget
Widget?
Custom content widget
actions
List<ChromiaDialogAction>?
Action buttons
width
double?
Width of the dialog
contentPadding
EdgeInsetsGeometry?
Padding for content

ChromiaDialogAction

An action button for dialogs.

Constructor

const ChromiaDialogAction({
  required String label,
  required VoidCallback onPressed,
  bool isPrimary = false,
  bool isDestructive = false,
})

Parameters

label
String
required
Button label
onPressed
VoidCallback
required
Callback when pressed
isPrimary
bool
default:"false"
Whether this is the primary action (highlighted)
isDestructive
bool
default:"false"
Whether this is a destructive action (shown in red)

showChromiaAlert

Shows an alert dialog with a single action.

Basic Usage

await showChromiaAlert(
  context: context,
  title: 'Success',
  message: 'Your changes have been saved.',
);

Parameters

context
BuildContext
required
Build context
title
String
required
Title text
message
String
required
Message text
actionLabel
String
default:"'OK'"
Label for the action button
onPressed
VoidCallback?
Callback when pressed (defaults to closing dialog)

showChromiaConfirmDialog

Shows a confirmation dialog with cancel and confirm actions.

Basic Usage

final confirmed = await showChromiaConfirmDialog(
  context: context,
  title: 'Delete Item',
  message: 'Are you sure you want to delete this item?',
  confirmLabel: 'Delete',
  isDestructive: true,
);

if (confirmed) {
  // Delete the item
}

Parameters

context
BuildContext
required
Build context
title
String
required
Title text
message
String
required
Message text
cancelLabel
String
default:"'Cancel'"
Label for the cancel button
confirmLabel
String
default:"'Confirm'"
Label for the confirm button
isDestructive
bool
default:"false"
Whether this is a destructive action

Returns

Returns Future<bool> - true if confirmed, false if cancelled.

showChromiaBottomSheet

Shows a bottom sheet dialog.

Basic Usage

await showChromiaBottomSheet(
  context: context,
  child: Container(
    padding: EdgeInsets.all(16),
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        ListTile(
          leading: Icon(Icons.share),
          title: Text('Share'),
          onTap: () {
            Navigator.pop(context);
          },
        ),
        ListTile(
          leading: Icon(Icons.link),
          title: Text('Copy Link'),
          onTap: () {
            Navigator.pop(context);
          },
        ),
      ],
    ),
  ),
);

Parameters

context
BuildContext
required
Build context
child
Widget
required
Content widget
isDismissible
bool
default:"true"
Whether the sheet can be dismissed by tapping outside
enableDrag
bool
default:"true"
Whether the sheet can be dragged to dismiss
backgroundColor
Color?
Background color

ChromiaLoadingDialog

A loading dialog that shows a progress indicator.

Show Loading

ChromiaLoadingDialog.show(
  context: context,
  message: 'Loading...',
);

// Do some work
await Future.delayed(Duration(seconds: 2));

// Hide loading
ChromiaLoadingDialog.hide(context);

Parameters

message
String?
Loading message to display

Methods

show
static Future<void>
Shows the loading dialog
static Future<void> show({
  required BuildContext context,
  String? message,
})
hide
static void
Hides the loading dialog
static void hide(BuildContext context)

Complete Example

class DialogExample extends StatelessWidget {
  Future<void> _saveChanges(BuildContext context) async {
    // Show confirmation
    final confirmed = await showChromiaConfirmDialog(
      context: context,
      title: 'Save Changes',
      message: 'Do you want to save your changes?',
      confirmLabel: 'Save',
    );

    if (!confirmed) return;

    // Show loading
    ChromiaLoadingDialog.show(
      context: context,
      message: 'Saving changes...',
    );

    try {
      // Simulate API call
      await Future.delayed(Duration(seconds: 2));

      // Hide loading
      ChromiaLoadingDialog.hide(context);

      // Show success
      await showChromiaAlert(
        context: context,
        title: 'Success',
        message: 'Your changes have been saved successfully.',
      );
    } catch (e) {
      // Hide loading
      ChromiaLoadingDialog.hide(context);

      // Show error
      await showChromiaAlert(
        context: context,
        title: 'Error',
        message: 'Failed to save changes: $e',
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: ChromiaAppBar(title: 'Dialog Example'),
      body: Center(
        child: ChromiaButton(
          label: 'Save Changes',
          onPressed: () => _saveChanges(context),
        ),
      ),
    );
  }
}

Build docs developers (and LLMs) love