switchOffUSBTether method

Future<bool> switchOffUSBTether()

Disables USB tethering on the device.

This method attempts to turn off USB tethering by invoking a platform-specific call.

Returns a Future containing a bool indicating whether USB tethering was successfully disabled. Returns false if an error occurs while disabling USB tethering.

Implementation

Future<bool> switchOffUSBTether() async {
  try {
    final bool result = await androidPlatform.invokeMethod('setUsbTethering', {'status': false});
    return result; // Return the result of the tethering operation.
  } on PlatformException catch (e) {
    debugPrint("Failed to disable tethering: '${e.message}'.");
    return false; // Return false in case of an error.
  }
}