serverWebSocketUri property Null safety

Uri? serverWebSocketUri

The Uri to connect to the service via web socket. If the web server is not running, this will be null.


Uri? get serverWebSocketUri {
  Uri? uri = serverUri;
  if (uri != null) {
    final pathSegments = <String>[];
    if (uri.pathSegments.isNotEmpty) {
        // Strip out the empty string that appears at the end of path segments.
        // Empty string elements will result in an extra '/' being added to the
        // URI.
        (s) => s.isNotEmpty,
    uri = uri.replace(scheme: 'ws', pathSegments: pathSegments);
  return uri;