formatKey static method

String formatKey(
  1. InternetAddress address,
  2. int port
)

Format an InternetAddress and port into a key string Format:

  • IPv4: "192.168.1.100:8080"
  • IPv6: "2001:db8::1:8080"

Implementation

static String formatKey(InternetAddress address, int port) {
  if (address.type == InternetAddressType.IPv6) {
    return '[${address.address}]:$port';
  }
  return '${address.address}:$port';
}