chore: fix Flutter baseline checks

This commit is contained in:
Artem Kokos
2026-04-22 21:08:02 +07:00
parent 8198ea09ae
commit ffc2ea1544
12 changed files with 68 additions and 54 deletions

View File

@@ -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);