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

BottomSheetCommand

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

Свойства​

СвойствоТипОписание
actionOverlayActionДействие (open или close)
contentMap<String, dynamic>Содержимое BottomSheet (дерево виджетов)
isScrollControlledboolУправление прокруткой содержимого
isDismissibleboolМожно ли закрыть касанием за пределами (по умолчанию true)
useSafeAreaboolИспользовать безопасную область
useRootNavigatorboolИспользовать корневой навигатор
enableDragboolРазрешить перетаскивание (по умолчанию true)
showDragHandlebool?Показывать ручку для перетаскивания
scrollControlDisabledMaxHeightRatiodoubleМаксимальное соотношение высоты
backgroundColorColor?Цвет фона
barrierColorColor?Цвет барьера
shapeShapeBorder?Форма границы
clipBehaviorClip?Поведение обрезки
constraintsBoxConstraints?Ограничения размера
anchorPointOffset?Точка привязки
onCloseServerAction?Действие при закрытии

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

final class BottomSheetCommand extends RemoteCommand {
final OverlayAction action;
final Map<String, dynamic> content;
final bool isScrollControlled;
final bool isDismissible;
final bool useSafeArea;
final bool useRootNavigator;
final bool enableDrag;
final bool? showDragHandle;
final double scrollControlDisabledMaxHeightRatio;
final Color? backgroundColor;
final Color? barrierColor;
final ShapeBorder? shape;
final Clip? clipBehavior;
final BoxConstraints? constraints;
final Offset? anchorPoint;
final ServerAction? onClose;

const BottomSheetCommand({...});

factory BottomSheetCommand.fromRemoteCommand(RemoteCommand command);
}

OverlayAction​

enum OverlayAction {
open, // Открыть модальное окно
close, // Закрыть модальное окно
}

Пример JSON​

Открытие BottomSheet​

{
"type": "command",
"controllerId": "overlay",
"commandData": {
"type": "bottomSheet",
"action": "open",
"content": {
"type": "Container",
"attributes": {
"padding": {"top": 16, "bottom": 16, "left": 16, "right": 16}
},
"child": {
"type": "Text",
"attributes": {
"data": "Hello from BottomSheet!"
}
}
},
"isScrollControlled": true,
"isDismissible": true,
"enableDrag": true,
"showDragHandle": true,
"backgroundColor": "#FFFFFF"
}
}

Закрытие BottomSheet​

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

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

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

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