Search code examples
flutterbluetoothbeacon

Anyone knows whay Flutter_beacon Randomly stops working or may suggest another plugin


I'm using flutter_beacon plugin, It was working awesome on android. Ranging the close devices and getting the information that the beacon was broadcasting. But now, It suddenly stops reading the information, as the beacon would have disappeared. Any suggestions how to fix this?? The library im using is this one: https://pub.dev/packages/flutter_beacon


Solution

  • I've identified an issue with beacon ranging on Android where the beacons temporarily disappear, causing potential disruptions in the app's functionality, especially when events are triggered on beacon ranging. To address this, I've implemented a simple fix in the code. During each interval, I check the RSSI values of the beacons. If the RSSI value is 0, indicating a temporary disappearance, I print the beacon details. Otherwise, I clear and update the beacon list to prevent disruptions. This ensures that the app maintains proper functionality even during moments of temporary beacon unavailability.

    Feel free to let me know if you need further clarification or if you have additional question

    result.beacons.forEach((beacon) {
              if (_regionBeacons[result.region][0].rssi == 0) {
                print('major: ${beacon.major} \n minor: ${beacon.minor} \n rssi: ${beacon.rssi}');
              } else {
                controller.beacons.clear();
                _regionBeacons.values.forEach((list) {
                  controller.beacons.addAll(list);
                });
              }
            });