getIP static method

Future<String?> getIP()

Implementation

static Future<String?> getIP() async {
  try {
    if (kIsWeb) {
      var response =
          await http.get(Uri(scheme: "https", host: 'api.ipify.org'));
      if (response.statusCode == 200) {
        ZugClient.log.fine(response.body);
        return response.body;
      } else {
        ZugClient.log.info(response.body);
        return null;
      }
    } else {
        List<NetworkInterface> list = await NetworkInterface.list();
        return list.first.addresses.first.address;
    }
  } catch (exception) {
    ZugClient.log.info(exception);
    return null;
  }
}