stream property
The stream of Measurements to forward. Implemented by subclasses.
Read on the first resume after creation or a pause.
Implementation
@override
Stream<Measurement> get stream async* {
await for (final monitoringResult in flutterBeacon.monitoring(beaconRegions)) {
if (monitoringResult.monitoringState == MonitoringState.inside) {
debug('$runtimeType - Entered region: ${monitoringResult.region.identifier}');
yield* flutterBeacon.ranging(beaconRegions).map((rangingResult) {
final closeBeacons = rangingResult.beacons.where((beacon) => beacon.accuracy <= beaconDistance).toList();
return Measurement.fromData(
BeaconData.fromRegionAndBeacons(region: rangingResult.region.identifier, beacons: closeBeacons),
);
});
} else if (monitoringResult.monitoringState == MonitoringState.outside) {
debug('$runtimeType - Exited region: ${monitoringResult.region.identifier}');
}
}
}