startBluetoothScan function
Implementation
Future<List<Vehicle>> startBluetoothScan() async {
// USE bluetoothScanEventStream.
String result = await platform.invokeMethod('startBluetoothScan');
if (kDebugMode) {
print("Scanned all nearby Devices: $result");
}
var decodedList = jsonDecode(result);
if (kDebugMode) {
print("decoded Scanned Devices: $decodedList");
}
List<Vehicle> list = List<Vehicle>.from(
decodedList.map((model) {
Vehicle vehicle = Vehicle.fromJson(model);
return vehicle;
}),
);
if (kDebugMode) {
print("-> Scanned nearby Devices list: $list");
}
return list;
}