chore: fix Flutter baseline checks
This commit is contained in:
@@ -73,9 +73,12 @@ Future<bool> executeGeofenceCheck() async {
|
||||
try {
|
||||
// Сначала lastKnown (мгновенно)
|
||||
pos = await Geolocator.getLastKnownPosition();
|
||||
// Если старше 5 минут -- запрашиваем свежую
|
||||
final lastTimestamp = pos?.timestamp;
|
||||
|
||||
// Если позиции нет или она несвежая -- запрашиваем новую
|
||||
if (pos == null ||
|
||||
DateTime.now().difference(pos.timestamp).inMinutes > 5) {
|
||||
lastTimestamp == null ||
|
||||
DateTime.now().difference(lastTimestamp).inMinutes > 5) {
|
||||
pos = await Geolocator.getCurrentPosition(
|
||||
locationSettings: const LocationSettings(
|
||||
accuracy: LocationAccuracy.low,
|
||||
@@ -87,8 +90,6 @@ Future<bool> executeGeofenceCheck() async {
|
||||
return true; // не удалось получить позицию
|
||||
}
|
||||
|
||||
if (pos == null) return true;
|
||||
|
||||
// 4. Считаем расстояние
|
||||
final homeLat = (targetHome['latitude'] as num).toDouble();
|
||||
final homeLon = (targetHome['longitude'] as num).toDouble();
|
||||
@@ -249,4 +250,4 @@ double _haversineMeters(
|
||||
return earthRadiusM * c;
|
||||
}
|
||||
|
||||
double _degToRad(double deg) => deg * (math.pi / 180);
|
||||
double _degToRad(double deg) => deg * (math.pi / 180);
|
||||
|
||||
Reference in New Issue
Block a user