unsubscribeFromCharacteristic method
Unsubscribes from a Bluetooth characteristic.
This method stops listening for updates for a given characteristic on a specified device.
Implementation
@override
void unsubscribeFromCharacteristic(BleCharacteristic characteristic) {
try {
channel.invokeMethod('unsubscribeFromCharacteristic', {
'address': characteristic.address,
'characteristicUuid': characteristic.uuid,
});
} on PlatformException catch (e) {
// Handle different error types accordingly.
if (e.message?.contains('permissions') ?? false) {
throw BluetoothPermissionException('Permission error: ${e.message}');
} else {
throw BluetoothSubscriptionException(
'Failed to unsubscribe from BLE characteristic: ${e.message}',
);
}
}
}