isIPv4 static method

bool isIPv4(
  1. String host
)

Returns true if the host is an IPv4 address.

Implementation

static bool isIPv4(String host) {
  final parts = host.split('.');
  if (parts.length != 4) return false;

  for (final part in parts) {
    final value = int.tryParse(part);
    if (value == null || value < 0 || value > 255) return false;
  }
  return true;
}