sendToFrontend method

void sendToFrontend(
  1. int? id,
  2. Map? result
)

Implementation

void sendToFrontend(int? id, Map? result) {
  assert(_ws != null, 'WebSocket should connect.');

  String data = jsonEncode({
    if (id != null) 'id': id,
    // Give an empty object for response.
    'result': result ?? {},
  });
  _ws!.add(data);
}