getPairedDevices function

Future<List<Vehicle>> getPairedDevices()

Implementation

Future<List<Vehicle>> getPairedDevices() async {
  // USE bluetoothScanEventStream in future.
  if (Platform.isIOS) {
    return [];
  }
  String result = await platform.invokeMethod('getPairedDevices');
  if (kDebugMode) {
    print("Received All Paired Devices: $result");
  }
  var decodedList = jsonDecode(result);
  if (kDebugMode) {
    print("decoded All Paired Devices: $decodedList");
  }
  List<Vehicle> list = List<Vehicle>.from(
    decodedList.map((model) {
      Vehicle vehicle = Vehicle.fromJson(model);
      return vehicle;
    }),
  );

  if (kDebugMode) {
    print("-> All Paired Devices list: $list");
  }

  return list;
}