parse_ipv4_part static method
Checks if the given string is a valid IPv4 address
Example:
IPAddress::valid_ipv4? "2002::1" //=> false
IPAddress::valid_ipv4? "172.16.10.1" //=> true
Implementation
static Result<int, String> parse_ipv4_part(String i, String addr) {
final part = i;
if (int.tryParse(part) == null) {
return Result.error("IP must contain numbers ${addr}");
}
if (int.parse(part) >= 256) {
return Result.error("IP items has to lower than 256. ${addr}");
}
return Result.ok(int.parse(part));
}