broadcast method Null safety

void broadcast(
  1. dynamic data,
  2. {bool where(
    1. C
    )?}
)

Implementation

void broadcast(dynamic data, {bool Function(C)? where}) {
	if (data is PackMeMessage) data = _packMe.pack(data);
	else if (data is! Uint8List && data is! String) {
		onError?.call('Unsupported data type for ConnectMe.broadcast(), only PackMeMessage, Uint8List and String are supported');
		return;
	}
	for (final C client in clients) {
		if (where != null && !where(client)) continue;
		if (data != null && client.socket.state == WebSocket.open) client.socket.add(data);
	}
}