fromString static method
Create RemoteInfo from string format "address:port" Returns null if the format is invalid or the address/port cannot be parsed
Implementation
static RemoteInfo? fromString(String formatted) {
final parsed = parseAddress(formatted);
if (parsed == null) return null;
final port = parsed['port'] as int;
// Validate port range
if (port < 0 || port > 65535) {
return null;
}
try {
final address = InternetAddress(parsed['address'] as String);
return RemoteInfo(address: address, port: port);
} on SocketException {
// Invalid IP address format
return null;
} catch (e) {
// Other errors
return null;
}
}