isIPv6 static method

bool isIPv6(
  1. String host
)

Returns true if the host is an IPv6 address.

Implementation

static bool isIPv6(String host) {
  // Basic IPv6 validation
  if (!host.contains(':')) return false;
  if (host.contains(':::')) return false;

  final parts = host.split(':');
  if (parts.length > 8) return false;

  for (final part in parts) {
    if (part.isEmpty) continue;
    if (int.tryParse(part, radix: 16) == null) return false;
  }
  return true;
}