connect static method

WebSocketChannel connect(
  1. Uri uri, {
  2. List<String>? protocols,
  3. Map<String, String>? headers,
})

Implementation

static WebSocketChannel connect(
  Uri uri, {
  List<String>? protocols,
  Map<String, String>? headers,
}) {
  // Web platform doesn't support headers in WebSocket constructor
  // Headers would need to be sent as part of the initial handshake or via query params
  if (protocols != null && protocols.isNotEmpty) {
    return WebSocketChannel.connect(uri, protocols: protocols);
  }
  return WebSocketChannel.connect(uri);
}