sortDevices method
void
sortDevices()
Implementation
void sortDevices() {
_devices
.removeWhere((element) => element.name == null || element.name == '');
// remove items having same vendorId
Set<String> seen = {};
_devices.retainWhere((element) {
String uniqueKey = '${element.vendorId}_${element.address}';
if (seen.contains(uniqueKey)) {
return false; // Remove duplicate
} else {
seen.add(uniqueKey); // Mark as seen
return true; // Keep
}
});
_devicesstream.add(_devices);
}