IPAddress constructor

IPAddress(
  1. String? str
)

Returns a valid IPAddress object.

Throws ValueException:

Implementation

factory IPAddress(String? str) {
  if (str == null || str.isEmpty) {
    throw const RequiredValueException();
  }

  if (isIP(str, '4')) {
    return IPAddress._(str, IPVersion.v4);
  } else if (isIP(str, '6')) {
    return IPAddress._(str, IPVersion.v6);
  }

  throw InvalidValueException(
    str,
    message: '$str is not a valid IP address',
  );
}