Open eggysudianto opened 3 years ago
You should store the stream subscription as a property in the widget so you can cancel it in the setState and set it to null
If you don't need the loop, you can try removing the repeating values and only display your updated uniques-beacons.
Try to make a new Map of your ranging then join to the map the result with a forEach, you can delete all duplicates values with this:
setState(() {
_regionBeacons[result.region] = result.beacons;
_beacons.clear();
final Map<dynamic, Beacon> profileMap = new Map();
result.beacons.forEach((item) {
profileMap[item.macAddress] = item;
});
_beacons.addAll(profileMap.values);
_beacons.sort(_compareParameters);
});
how to stop beacon from ranging if already found which beacon I want
this my code.
_streamRanging.cancel();
is never called because beacon always ranging even though I break the looping