getIndoorBeacons method
The function getIndoorBeacons
returns a Future that retrieves a list of IndoorBeacon objects inside an indoor venue using the
GeofencingFlutterPluginPlatform.
@param {String} venueID
- The optional venueID
parameter is a String that represents the ID of an indoor venue for which the beacons will be fetched.
@param {String} ref
- The optional ref
parameter is a String that represents the identifier of the beacon which needs to be fetched.
@returns The method is returning a Future
object that resolves to a List of IndoorBeacon objects for the given venue or the given ref or both.
Implementation
@override
Future<List<IndoorBeacon>?> getIndoorBeacons(
String? venueID, String? ref) async {
final returnVal =
await methodChannel.invokeMethod<String>('getIndoorBeacons', venueID);
List<IndoorBeacon>? indoorBeacons;
if (returnVal != null) {
indoorBeacons = (jsonDecode(returnVal) as List)
.map((i) => IndoorBeacon.jsonToObj(i))
.toList();
if (ref != null) {
List<IndoorBeacon> filteredList = [];
for (IndoorBeacon indoorBeacon in indoorBeacons) {
if (indoorBeacon.identifier == ref) {
filteredList.add(indoorBeacon);
}
}
return filteredList;
}
}
return indoorBeacons;
}