scanBluetooth method
Future<void>
scanBluetooth(
)
override
Implementation
@override
Future<void> scanBluetooth() async {
try {
final stream = bltDeviceEvent.receiveBroadcastStream();
final mappedStream = stream.map((e) => e is List<dynamic>
? e.map(BluetoothDevice.fromDynamic).toList()
: null);
deviceSub = mappedStream.listen((e) {
cachedDevices = e;
deviceCtr.sink.add(e);
});
await bltMethodChannel.invokeMethod('scanBluetooth');
} on PlatformException catch (e) {
if (e.code == 'BluetoothException') {
throw BluetoothException(e.message);
}
throw Exception(e.message);
}
}