getDeviceAddress method

Future<String?> getDeviceAddress()

Retrieves the device's internal IP address.

This method makes a platform-specific call to obtain the device's internal IP address.

Returns a Future containing the device IP address as a String if successful. Returns null if an error occurs while fetching the device IP address.

Implementation

Future<String?> getDeviceAddress() async {
  try {
    final String result = await androidPlatform.invokeMethod('getDeviceAddress');
    return result; // Return the fetched device IP address.
  } on PlatformException catch (e) {
    debugPrint("Failed to get Device IP address: '${e.message}'.");
    return null; // Return null in case of an error.
  }
}