Skip to main content

DialogCommand

The class represents a command for showing or hiding a dialog window. Extends RemoteCommand.

Properties​

PropertyTypeDescription
actionOverlayActionAction (open or close)
contentMap<String, dynamic>Dialog content (widget tree)
barrierDismissibleboolCan be dismissed by tapping outside (default true)
useSafeAreaboolUse safe area (default true)
useRootNavigatorboolUse root navigator (default true)
barrierColorColor?Barrier color
barrierLabelString?Barrier label for accessibility
anchorPointOffset?Anchor point
onCloseServerAction?Action on close

Class Definition​

final class DialogCommand extends RemoteCommand {
final OverlayAction action;
final Map<String, dynamic> content;
final bool barrierDismissible;
final bool useSafeArea;
final bool useRootNavigator;
final Color? barrierColor;
final String? barrierLabel;
final Offset? anchorPoint;
final ServerAction? onClose;

const DialogCommand({...});

factory DialogCommand.fromRemoteCommand(RemoteCommand command);
}

OverlayAction​

enum OverlayAction {
open, // Open dialog window
close, // Close dialog window
}

JSON Examples​

Opening Dialog​

{
"type": "command",
"controllerId": "overlay",
"commandData": {
"type": "dialog",
"action": "open",
"content": {
"type": "AlertDialog",
"attributes": {
"title": "Confirmation",
"content": "Are you sure you want to continue?"
}
},
"barrierDismissible": true,
"useSafeArea": true,
"barrierColor": "#80000000"
}
}

Closing Dialog​

{
"type": "command",
"controllerId": "overlay",
"commandData": {
"type": "dialog",
"action": "close"
}
}

With Close Handler​

{
"type": "command",
"controllerId": "overlay",
"commandData": {
"type": "dialog",
"action": "open",
"content": {...},
"barrierDismissible": false,
"onClose": {
"executionType": 0,
"event": "/on-dialog-closed"
}
}
}