isPrivate method
Implementation
bool isPrivate() {
final ip = toIP();
if (ip == null) return false;
final addr = ip.address;
if (ip.type == InternetAddressType.IPv4) {
// Check private IPv4 ranges
if (addr.startsWith('10.')) return true;
if (addr.startsWith('172.') &&
int.parse(addr.split('.')[1]) >= 16 &&
int.parse(addr.split('.')[1]) <= 31) return true;
if (addr.startsWith('192.168.')) return true;
} else {
// Check private IPv6 ranges
if (addr.toLowerCase().startsWith('fc')) return true;
if (addr.toLowerCase().startsWith('fd')) return true;
}
return false;
}