getPCAddress method

Future<String?> getPCAddress()

Retrieves the IP address of the current network interface.

This method invokes a platform-specific call to get the IP address of the device's active network connection.

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

Implementation

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