Skip to main content

RemoteCommand

Base class representing a command sent to control actions of a controller. The command defines the action type and contains data for its execution.

Properties​

PropertyTypeDescription
controllerIdStringIdentifier of the controller that the command is addressed to
typeStringCommand type (animation, bottomSheet, dialog, pageView, focusNode)
commandDataMap<String, dynamic>Command-specific data

Class Definition​

base class RemoteCommand {
final String controllerId;
final String type;
final Map<String, dynamic> commandData;

const RemoteCommand({
required this.controllerId,
required this.type,
required this.commandData,
});
}

Supported Command Types​

TypeClassDescription
animationAnimationCommandProperty animation control
bottomSheetBottomSheetCommandShow/hide modal bottom sheets
dialogDialogCommandShow/hide dialog windows
pageViewPageViewCommandPageView/PageController management
focusNodeFocusNodeCommandFocus management for elements

JSON Example​

{
"type": "command",
"controllerId": "widget_id",
"commandData": {
"type": "animation",
"animatedPropKey": "style",
"method": 0,
"trigger": "onAction"
}
}

Usage​

Commands are sent via CommandEvent and processed by widget controllers. Each command type has its specialized implementation that extends RemoteCommand.

// Example of listening to commands in a controller
controller.listenCommand((command) async {
switch (command) {
case AnimationCommand(:final method, :final animatedPropKey):
// Handle animation command
break;
case BottomSheetCommand(:final action, :final content):
// Handle bottom sheet command
break;
// ...
}
});