fromString static method
Implementation
// ignore: prefer_constructors_over_static_methods
static Ipv4Address fromString(
String? value, {
String separator = '.',
}) {
if (value == null || value.isEmpty) {
throw ArgumentError('invalidIpAddress');
}
List<String> parts = value.split(separator);
if (parts.length != 4) {
throw ArgumentError('invalidIpAddress');
}
List<int> ocs = <int>[];
for (final String part in parts) {
int? octet = int.tryParse(part);
if (octet == null || octet < 0 || octet > 255) {
throw ArgumentError('invalidIpAddress');
}
ocs.add(octet);
}
return Ipv4Address.fromDecimals(ocs[0], ocs[1], ocs[2], ocs[3]);
}