stopScan method
Stops an ongoing Bluetooth scan and handles any potential errors.
Implementation
@override
Future<void> stopScan() async {
try {
// Stop the scan and wait for the method to complete.
await channel.invokeMethod('stopScan');
} on PlatformException catch (e) {
// Handle different error types accordingly.
if (e.message?.contains('permissions') ?? false) {
throw BluetoothPermissionException('Permission error: ${e.message}');
} else {
throw BluetoothScanException(
'Failed to stop Bluetooth scan: ${e.message}',
);
}
}
}