sendCmd method

void sendCmd(
  1. String command, {
  2. Map<String, Object?>? data,
})

Send a structured command to the isolate.

Convenience method for sending commands with optional data payload. The command is automatically added to the data map for structured processing on the receiving end.

Example:

// Send a processing command
workerPort.sendCmd('process_data', data: {
  'input': largeDataset,
  'options': processingOptions,
});

Implementation

@pragma('vm:prefer-inline')
void sendCmd(String command, {Map<String, Object?>? data}) {
  final payload = <String, Object?>{...?data, 'command': command};
  send(payload);
}