tryParse static method

ChatInviteLink? tryParse(
  1. Uri uri, {
  2. String roomParam = 'room',
  3. String tokenParam = 'token',
})

Parses uri, returning a ChatInviteLink when both the roomParam and tokenParam query parameters are present and non-empty, or null otherwise (so callers can if (link != null) straight onto the join).

Implementation

static ChatInviteLink? tryParse(
  Uri uri, {
  String roomParam = 'room',
  String tokenParam = 'token',
}) {
  final roomId = uri.queryParameters[roomParam];
  final token = uri.queryParameters[tokenParam];
  if (roomId == null || roomId.isEmpty || token == null || token.isEmpty) {
    return null;
  }
  return ChatInviteLink(roomId: roomId, token: token);
}