getFirstIpAddress static method

Future<String?> getFirstIpAddress()

Get the first ip address found in the NetworkInterface.list().

Implementation

static Future<String?> getFirstIpAddress() async {
  for (var interface in await NetworkInterface.list()) {
    for (var addr in interface.addresses) {
      return addr.address;
    }
  }
  return null;
}