getIpAddressText method

  1. @override
Future<String> getIpAddressText()
override

Get IpAddress in text format.

Implementation

@override
Future<String> getIpAddressText() async {
  try {
    var response = await http.get(
      Uri.parse(
        'https://api64.ipify.org',
      ),
    );
    if (response.statusCode == 200) {
      return response.body;
    } else {
      throw IpAddressException('Not able to find the Ip Address.');
    }
  } catch (_) {
    throw IpAddressException('Not able to find the Ip Address.');
  }
}