unpairPrinter method

Future<bool> unpairPrinter(
  1. String address
)

Unpairs a Bluetooth device Uses Android Bluetooth API to remove bonding

Returns true if successful, throws exception otherwise

Implementation

Future<bool> unpairPrinter(String address) async {
  try {
    log('[PrinterManager] unpairPrinter called for: $address');

    if (Platform.isAndroid) {
      final bool granted = await checkAndRequestPermissions();
      if (!granted) {
        throw Exception("Bluetooth permissions not granted.");
      }
    }

    final result = await _channel.invokeMethod('unpairPrinter', {'address': address});
    log('[PrinterManager] unpairPrinter successful');
    return result as bool;
  } on PlatformException catch (e) {
    log('[PrinterManager] unpairPrinter error: ${e.code} - ${e.message}');
    throw Exception("Unpair Printer Error (${e.code}): ${e.message}");
  }
}