localIp static method

Future<String?> localIp()

The first non-loopback IPv4 address (the one other devices on the LAN would use).

Implementation

static Future<String?> localIp() async {
  final List<UNetworkAddress> all = await addresses();
  for (final UNetworkAddress a in all) {
    if (!a.isIPv6 && !a.isLinkLocal) return a.address;
  }
  return all.isEmpty ? null : all.first.address;
}