isValidIPv4 static method

bool isValidIPv4(
  1. String ip
)

Validates if the given string is a valid IPv4 address.

Implementation

static bool isValidIPv4(String ip) {
  final regex = RegExp(r'^((25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.|\b)){4}\$');
  return regex.hasMatch(ip);
}