getPublicIP method
Implementation
Future<String?> getPublicIP() async {
try {
const url = 'https://api.ipify.org';
var response = await Dio().get(url);
log("getPublicIP:[Status Code] - ${response.statusCode}");
if (response.statusCode == 200) {
return response.data;
} else {
log("getPublicIP:[Status Code] - ${response.data}");
return null;
}
} on DioException catch (dioError) {
log("getPublicIP:[dioError] - ${dioError.response?.data}");
return null;
} catch (e) {
log("getPublicIP:[Catch] - $e");
return null;
}
}