I have a flutter project where I'm using a library named flutter_blue.
When I scan for bluetooth devices I'm getting a list of devices and also the signal strength measured in decibels (RSSI).
The question is how can I sort that list of devices by RSSI property which I have it for each device found ?
Here is a link to my source code:
Here is my block of code where I think I should do the sort by r.rssi but I can't manage to do it.
StreamBuilder<List<ScanResult>>(
stream: FlutterBlue.instance.scanResults,
initialData: [],
builder: (c, snapshot) => Column(
children: snapshot.data
.map(
(r) => ScanResultTile(
result: r,
onTap: () => Navigator.of(context)
.push(MaterialPageRoute(builder: (context) {
r.device.connect();
return DeviceScreen(device: r.device);
})),
),
)
.toList(),
),
),
Thanks for reading this.