import 'package:flutter/foundation.dart' show kIsWeb; import 'package:permission_handler/permission_handler.dart'; import '../services/permission_service.dart'; /// Helpers for requesting and checking the platform location permission. /// /// Mirrors the pattern in [notification_permission.dart] so that location /// can be requested at app launch and before location-dependent actions. Future requestLocationPermission() async { if (kIsWeb) { return PermissionStatus.granted; } return requestPermission(Permission.location); } /// Ensures location permission is granted. Returns `true` if granted. /// /// Call on app launch and before check-in, check-out, or toggling location /// tracking so the user always has the opportunity to grant permission. Future ensureLocationPermission() async { if (kIsWeb) return true; final status = await Permission.location.status; if (status.isGranted) return true; if (status.isDenied || status.isRestricted || status.isLimited) { final newStatus = await requestLocationPermission(); return newStatus.isGranted; } // permanently denied – user must open settings return false; }