From 8c73ba088b521d2586e52117f11cd4b0fb296afb Mon Sep 17 00:00:00 2001 From: Siahlooei Date: Sat, 20 Jul 2024 15:50:07 +0330 Subject: [PATCH] Starting using geolocation. --- lib/provider/location.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/provider/location.dart b/lib/provider/location.dart index 4fb16b9..a61b0e8 100644 --- a/lib/provider/location.dart +++ b/lib/provider/location.dart @@ -6,13 +6,12 @@ part 'location.g.dart'; @riverpod class MyLocation extends _$MyLocation { - MyLocation() { - /* + Future _detertimeLocation() async { bool serviceEnabled; LocationPermission permission; // Test if location services are enabled. - serviceEnabled = Geolocator.isLocationServiceEnabled().then(onValue); + serviceEnabled = await Geolocator.isLocationServiceEnabled(); if (!serviceEnabled) { // Location services are not enabled don't continue // accessing the position and request users of the @@ -37,11 +36,13 @@ class MyLocation extends _$MyLocation { // Permissions are denied forever, handle appropriately. return Future.error( 'Location permissions are permanently denied, we cannot request permissions.'); - }*/ + } } @override Future build() async{ + await _detertimeLocation(); + Position l = Position(longitude: 0, latitude: 0, timestamp: DateTime.timestamp(), accuracy: 0, altitude: 0, altitudeAccuracy: 0, heading: 0, headingAccuracy: 0,