Перейти к основному содержимому

DialogCommand

Класс представляет команду для показа или скрытия диалогового окна. Наследуется от RemoteCommand.

Свойства​

СвойствоТипОписание
actionOverlayActionДействие (open или close)
contentMap<String, dynamic>Содержимое диалога (дерево виджетов)
barrierDismissibleboolМожно ли закрыть касанием за пределами (по умолчанию true)
useSafeAreaboolИспользовать безопасную область (по умолчанию true)
useRootNavigatorboolИспользовать корневой навигатор (по умолчанию true)
barrierColorColor?Цвет барьера
barrierLabelString?Метка барьера для доступности
anchorPointOffset?Точка привязки
onCloseServerAction?Действие при закрытии

Определение класса​

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, // Открыть диалоговое окно
close, // Закрыть диалоговое окно
}

Пример JSON​

Открытие диалога​

{
"type": "command",
"controllerId": "overlay",
"commandData": {
"type": "dialog",
"action": "open",
"content": {
"type": "AlertDialog",
"attributes": {
"title": "Подтверждение",
"content": "Вы уверены, что хотите продолжить?"
}
},
"barrierDismissible": true,
"useSafeArea": true,
"barrierColor": "#80000000"
}
}

Закрытие диалога​

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

С обработчиком закрытия​

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

Связанные типы​