sendToFrontend method
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);
}