Dialog
showPaymentConfirmDialog asks a yes-or-no question before an action that cannot be undone, and returns a Future<bool>.
Run the action only after the dialog resolves to true.
On a phone the confirmation is a bottom sheet; on a wider window it is a centred dialog. The page keeps the name “Dialog”.





Minimal
Section titled “Minimal”Add the published package, then paste this complete example into lib/main.dart.
import 'package:flutter/material.dart';import 'package:rakit_ui/rakit_ui.dart';
void main() => runApp(MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('Example')), body: Builder(builder: (context) => Padding( padding: const EdgeInsets.all(16), child: PaymentButton( label: 'Archive note', variant: PaymentButtonVariant.secondary, onPressed: () async { final confirmed = await showPaymentConfirmDialog( context, title: 'Archive this note?', message: 'You can restore it later.', confirmLabel: 'Archive', ); if (!context.mounted || !confirmed) return; ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Archive confirmed')), ); }, ), )), ),));Variants
Section titled “Variants”Variants: ordinary confirm, destructive confirm.
Result
Section titled “Result”The future resolves to true only when the person presses the confirm button. Cancel, tapping the scrim, Back and Escape all resolve to false.
Default
Section titled “Default”The confirm button is filled with the accent and the cancel button is a quiet text button. The confirm button receives focus first.
Destructive
Section titled “Destructive”destructive: true fills the confirm button in the danger tone, the same colors as a destructive button, and moves first focus to the cancel button, so Enter never confirms by accident.
Custom cancel label
Section titled “Custom cancel label”The cancel button says “Cancel” by default. Pass cancelLabel when the safe choice reads better as an action of its own, such as “Keep paying”.
Phone: confirm sheet
Section titled “Phone: confirm sheet”On a phone, when the window’s shorter side is under 600 dp, the confirmation slides up as a bottom sheet with no drag handle: the title, then the message, then the actions. The actions are stacked top-down at full width with centred labels, the confirm action on top and a quiet Cancel below. One 16 dp inset holds on every edge at every text scale, plus the bottom safe area. Language and text size never change the layout, so English, Indonesian and 200% text all look the same. At large text the title and message scroll, and the actions stay on screen. A phone held sideways (640 × 360 dp) keeps this sheet.
Wide: centred dialog
Section titled “Wide: centred dialog”On a tablet, with a shorter side of 600 dp or more, the confirmation is a centred dialog, at most 400 dp wide, with the same 16 dp edges. The actions are one row of equal-width buttons with Cancel first and the confirm action trailing.
Dismiss paths
Section titled “Dismiss paths”| Path | Phone sheet | Wide dialog | Result |
|---|---|---|---|
| Confirm button | yes | yes | true |
| Cancel button | yes | yes | false |
| Scrim tap | yes | yes | false |
| Swipe down | yes | — | false |
| Back | yes | yes | false |
| Escape | yes | yes | false |
| Enter | activates the focused button | activates the focused button | true only when the confirm action has focus |
Actions and focus
Section titled “Actions and focus”Cancel is quiet; Confirm is primary or destructive. Keyboard focus uses the neutral ring, starting on Cancel for destructive actions and on Confirm otherwise. Enter activates that safe initial choice. Opening a confirmation from inside a sheet, such as the focus view’s discard question, stacks a sheet on the sheet. That is expected.
Which variant when
Section titled “Which variant when”| Situation | Variant / composition | Payment example |
|---|---|---|
| Discard report | destructive confirm | Name the consequence and keep Cancel quiet; focus Cancel for destruction. |
Use Focus view for collecting a report.
States
Section titled “States”Confirm resolves to true. Cancel, Back, Escape and scrim dismissal resolve to false; the host performs the confirmed operation.
Confirm and wait for the host
Section titled “Confirm and wait for the host”Use showPaymentAsyncConfirmDialog when the prompt needs to stay open until a host action succeeds. It uses the same phone and tablet layouts, action order and initial focus. The async sheet disables swipe-to-dismiss so an in-flight operation cannot be dismissed by a drag; Cancel, scrim, Back and Escape work when idle.
final removed = await showPaymentAsyncConfirmDialog( context, title: 'Remove this statement?', description: ValueListenableBuilder<String>( valueListenable: confirmationMessage, builder: (_, message, _) => Semantics( liveRegion: true, child: Text(message), ), ), confirmLabel: 'Remove statement', pendingLabel: 'Removing statement', destructive: true, onConfirm: removeSelectedStatement,);The host’s removeSelectedStatement handles expected failures and returns Future<bool>. Return true only after confirming success. Return false to keep the prompt open and update confirmationMessage with safe recovery instructions. The async prompt uses the root navigator so system Back reaches it even when opened from a nested page. If the callback needs to await another route, open that route on the root navigator too so it appears above the prompt. While pending, the kit prevents repeated confirmation and user dismissal. pendingLabel is announced to assistive technology.
Check status without repeating a write
Section titled “Check status without repeating a write”Pass actionLabels if the next press may do something different. Its current value supplies the confirm and pending labels in place of the static strings. A null live pending label uses the localized working label. Keep the host-owned listenable alive until the dialog future completes. Updating it leaves the current dialog, button variant and pending locks in place.
final labels = ValueNotifier(const PaymentAsyncConfirmLabels( confirmLabel: 'Remove statement', pendingLabel: 'Removing statement',));var needsStatusCheck = false;var closed = false;try { await showPaymentAsyncConfirmDialog( context, title: 'Remove this statement?', description: const Text('It will no longer appear in saved records.'), confirmLabel: 'Remove statement', actionLabels: labels, destructive: true, onConfirm: () async { if (needsStatusCheck) return checkRemovalStatus(); final removed = await removeStatement(); // null: outcome unknown if (removed != null) return removed; if (closed) return false;
needsStatusCheck = true; labels.value = const PaymentAsyncConfirmLabels( confirmLabel: 'Check status', pendingLabel: 'Checking status', ); return false; }, );} finally { closed = true; labels.dispose();}checkRemovalStatus reads the outcome for the same record and returns true only when removal is confirmed. Do not blindly repeat a write with an unknown outcome. The kit never retries, and changing the label does not change what onConfirm does. The example gallery’s Kit components section shows a lost removal response followed by a status check, with live recovery copy in the description.
Do and don’t
Section titled “Do and don’t”Do: Name the consequence and keep Cancel quiet; focus Cancel for destruction.
Don’t: Ask for confirmation before every reversible interaction.
Content guidelines
Section titled “Content guidelines”- Ask the question in the title: “Remove this card?”, “Sign out of all devices?”.
- Use the message for the consequence, and for what is not affected: “Payments already sent are not affected.”
- Make
confirmLabelrepeat the action: “Sign out”, “Remove card”. Never “Yes” or “OK”. - Do not use a dialog to cancel a payment by itself. A cancel request goes to your host, and the payment stays pending until your host decides; see Sheet.
Accessibility
Section titled “Accessibility”Initial focus is on Cancel for destructive actions and Confirm otherwise. Dismissal returns false; labels and messages remain readable at large text.
In the example app
Section titled “In the example app”

showPaymentConfirmDialog
Future<bool> showPaymentConfirmDialog(…) · lib/src/interaction/interaction.dart
Asks before an action that cannot be undone. Resolves to true only when the person confirms; the scrim, swipe down, Back and Escape all resolve to false.
On phones (window shortest side under 600 dp, so also in landscape; D92) it is a bottom confirm sheet: title, message, then full-width actions stacked top-down with the confirm action on top and Cancel below (D45). On tablets it is a centred dialog with one row of equal-width buttons, confirm trailing. Both use one 16 dp inset at every text scale, so the layout never depends on label length.
For destructive actions the safe choice (cancel) receives focus first, so Enter never confirms by accident.
| Parameter | Type | Default | Description |
|---|---|---|---|
contextrequiredpositional | BuildContext | — | — |
title:required | String | — | — |
message:required | String | — | — |
confirmLabel:required | String | — | — |
cancelLabel: | String? | — | — |
destructive: | bool | false | — |
showPaymentAsyncConfirmDialog
Future<bool> showPaymentAsyncConfirmDialog(…) · lib/src/interaction/interaction.dart
Presents confirmation with the same responsive layout and initial focus as showPaymentConfirmDialog, but keeps it open while the host runs onConfirm.
title names the action. description is host content (including any recovery message), with the kit's supporting body style by default. confirmLabel names the operation and cancelLabel overrides localized Cancel. pendingLabel is the spoken busy status; it defaults to the kit's localized working label. For destructive actions, Cancel receives focus.
Pass actionLabels to update both labels while the prompt is open. Its value takes precedence over the static labels, including a null pending label. The host owns the listenable and must keep it alive until the returned future completes. Updating labels does not invoke onConfirm, unlock the prompt, or change the action's variant.
Return true from onConfirm only when the host confirms success. Return false to leave the prompt open and make the actions available again. The host handles expected failures and decides whether another activation may retry the operation or should only check its status. The kit never retries. Unexpected exceptions are reported to Flutter and leave the prompt open.
The prompt uses the root navigator. While pending, repeat activation, Cancel, scrim, Back and Escape cannot dismiss it. The async sheet does not support swipe-to-dismiss. The returned future is true only for confirmed success and false on dismissal. A host that force-removes the route does not cancel the operation.
| Parameter | Type | Default | Description |
|---|---|---|---|
contextrequiredpositional | BuildContext | — | — |
title:required | String | — | — |
description:required | Widget | — | — |
confirmLabel:required | String | — | — |
onConfirm:required | Future<bool> Function() | — | — |
cancelLabel: | String? | — | — |
pendingLabel: | String? | — | — |
actionLabels: | ValueListenable<PaymentAsyncConfirmLabels>? | — | — |
destructive: | bool | false | — |
PaymentAsyncConfirmLabels
class PaymentAsyncConfirmLabels · lib/src/interaction/interaction.dart
Action labels for an open showPaymentAsyncConfirmDialog.
| Parameter | Type | Default | Description |
|---|---|---|---|
confirmLabel:required | String | — | Visible and spoken name of the confirm action. |
pendingLabel: | String? | — | Spoken status while the action is running. Defaults to localized working. |