getConnectedWebSocket method Null safety

  1. @override
Future<WebSocketChannel> getConnectedWebSocket()
override

Returns a new WebSocketChannel, ready to be listened on.

This should be overriden by child classes, NOT connect.

Implementation

@override
Future<WebSocketChannel> getConnectedWebSocket() async {
  var socket = await WebSocket.connect(websocketUri.toString(),
      headers: authToken?.isNotEmpty == true
          ? {'Authorization': 'Bearer $authToken'}
          : {});
  return IOWebSocketChannel(socket);
}