import 'package:geolocator/geolocator.dart'; class LocationService { Future getCurrentPosition() async { bool serviceEnabled = await Geolocator.isLocationServiceEnabled(); if (!serviceEnabled) throw Exception('Location services disabled'); LocationPermission permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); if (permission == LocationPermission.denied) { throw Exception('Location permissions denied'); } } if (permission == LocationPermission.deniedForever) { throw Exception('Permissions permanently denied'); } return await Geolocator.getCurrentPosition( desiredAccuracy: LocationAccuracy.high, ); } }