fromJson static method
Implementation
static RealtimeConfig? fromJson(Object? value) {
if (value is! Map<String, dynamic> || value['driver'] != 'reverb') {
return null;
}
final key = value['key'];
final host = value['host'];
final port = value['port'];
final scheme = value['scheme'];
final authEndpoint = value['authEndpoint'];
if (key is! String ||
key.trim().isEmpty ||
host is! String ||
host.trim().isEmpty ||
port is! int ||
port < 1 ||
port > 65535 ||
scheme is! String ||
!const {'ws', 'wss'}.contains(scheme) ||
authEndpoint is! String ||
!authEndpoint.startsWith('/') ||
authEndpoint.startsWith('//')) {
return null;
}
return RealtimeConfig(
key: key.trim(),
host: host.trim(),
port: port,
scheme: scheme,
authEndpoint: authEndpoint,
);
}