computeAccuracy static method
LocationAccuracy
computeAccuracy({
- required ActivityType activity,
- double speedMps = 0.0,
- double batteryLevelPercent = 100.0,
- IndoorOutdoorState envState = IndoorOutdoorState.unknown,
Calculate recommended LocationAccuracy level.
Implementation
static LocationAccuracy computeAccuracy({
required ActivityType activity,
double speedMps = 0.0,
double batteryLevelPercent = 100.0,
IndoorOutdoorState envState = IndoorOutdoorState.unknown,
}) {
// Battery Saver / Low Battery override (< 15%)
if (batteryLevelPercent <= 15.0) {
if (activity == ActivityType.still) {
return LocationAccuracy.bestForNavigation;
}
return LocationAccuracy.bestForNavigation;
}
// Indoor signal attenuation mode (high accuracy to capture multi-path fixes)
if (envState == IndoorOutdoorState.indoor) {
return LocationAccuracy.bestForNavigation;
}
// High velocity movement (driving or cycling)
if (activity == ActivityType.inVehicle || speedMps >= 9.0) {
return LocationAccuracy.bestForNavigation;
}
// Pedestrian movement (walking, running, or cycling)
if (activity == ActivityType.walking ||
activity == ActivityType.running ||
activity == ActivityType.cycling ||
(speedMps >= 0.5 && speedMps < 9.0)) {
return LocationAccuracy.bestForNavigation;
}
// Stationary state
if (activity == ActivityType.still || speedMps < 0.5) {
return LocationAccuracy.bestForNavigation;
}
return LocationAccuracy.bestForNavigation;
}