initiateDeviceIpAddress method
Future<void>
initiateDeviceIpAddress(
)
override
Implementation
@override
Future<void> initiateDeviceIpAddress() async {
try {
final Dio dio = Dio();
final SharedPreferences _sharedPreferences =
await SharedPreferences.getInstance();
final response = await dio.get('https://api.ipify.org/?format=json');
if (response.statusCode == 200) {
final String currentIP = response.data['ip'];
await _sharedPreferences.setString('currentIP', currentIP);
}
} on Exception {
rethrow;
}
}