Skip to content

ApprovalPrompt

A yes/no decision dialog for one ApprovalRequest: title, explanation, optional subject and detail lines, and Approve/Deny buttons with y/n key shortcuts. Destructive requests focus Deny by default, so a stray Enter can’t trigger an irreversible action. For half a second after the prompt appears, or shows a request with a different ApprovalRequest.id, it ignores the keys and clicks that approve (y, and Enter, Space, or a click on Approve), so typing or a click meant for what was there before can’t approve it. Denying works at once.

See also: Dialog to build your own modal.

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

ApprovalPrompt(
onDecision: (d) {},
request: const ApprovalRequest(
id: 'a1',
title: 'Run on bare metal?',
message:
'This will reserve the terminal and write benchmark artifacts.',
subject: 'Tier-C benchmark',
),
)

The prompt’s semantic submit action approves at once, since an agent or assistive technology addresses it on purpose. A semantic press of the Approve button in that half second reports unsupported instead: the button can’t tell it from a key or a click.

Esc denies, as the semantic cancel action does. In a dialog shown with present, Esc answers the request through onDecision instead of closing the dialog around it. The route present makes can still close it unanswered, with null as present’s result: through the route’s semantic dismiss action, which an agent can invoke, or through NavigatorState.maybePop, as a Back command does. Pass barrierDismissible: false, as below, to turn both off, so every way out goes through onDecision. Close the prompt from there; popping with the decision makes it present’s result.

ParameterTypeDefaultDescription
request:ApprovalRequestrequiredRequest content and severity to present.
onDecision:void Function(ApprovalDecision decision)requiredCalled whenever the user approves or denies request: with a button, y or n, Esc (which denies), or a semantic action. The prompt doesn’t close itself; dismiss it from here.
width:int?56Total dialog width, including its border; null sizes to the content.
autofocusApprove:bool?—Whether the confirm button is focused on open. When null (the default), an ApprovalSeverity.destructive request focuses the deny button, so a single Enter can’t trigger an irreversible action, and other requests focus confirm. Pass an explicit value to override.

ApprovalPrompt is defined in packages/fleury/lib/src/catalog/approval_prompt.dart.

Category: Agent surfaces · All widgets