From 6a5e5e6a92f3abd12b550326aacac9da49355bf7 Mon Sep 17 00:00:00 2001 From: nishantsir57 Date: Thu, 6 Feb 2025 00:15:52 +0530 Subject: [PATCH 1/2] Fixed web Location Picking issue --- lib/src/location_picker.dart | 9 ++++++--- pubspec.yaml | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/location_picker.dart b/lib/src/location_picker.dart index 65d712b..7919df5 100644 --- a/lib/src/location_picker.dart +++ b/lib/src/location_picker.dart @@ -7,6 +7,7 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map_location_marker/flutter_map_location_marker.dart' as marker; +import 'package:geolocator/geolocator.dart'; import 'package:http/http.dart' as http; import 'package:intl/intl.dart' as intl; import 'package:latlong2/latlong.dart'; @@ -369,11 +370,13 @@ class _FlutterLocationPickerState extends State /// /// Returns: /// A Future object. - Future _determinePosition() async { + Future _determinePosition() async { try { // Test if location services are enabled. + // Position position = await Geolocator.getCurrentPosition(); await checkLocationPermission(); - return await location.getLocation(); + // return await location.getLocation(); + return await Geolocator.getCurrentPosition(); } catch (e) { rethrow; } @@ -518,7 +521,7 @@ class _FlutterLocationPickerState extends State if (widget.trackMyPosition) { _determinePosition().then((currentPosition) { initPosition = - LatLong(currentPosition.latitude!, currentPosition.longitude!); + LatLong(currentPosition.latitude, currentPosition.longitude); onLocationChanged(latLng: initPosition); _animatedMapMove(initPosition.toLatLng(), 18.0); diff --git a/pubspec.yaml b/pubspec.yaml index 032f6c7..d406650 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: url_launcher: ^6.2.1 flutter_map_location_marker: ^9.0.0 flutter_map_cancellable_tile_provider: ^3.0.0 + geolocator: ^13.0.2 dev_dependencies: flutter_lints: ^4.0.0 From d7439db9f73b608677fa30b1ed95131239cf6adf Mon Sep 17 00:00:00 2001 From: nishantsir57 Date: Thu, 6 Feb 2025 00:36:29 +0530 Subject: [PATCH 2/2] Fixed web Location Picking issue --- lib/src/location_picker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/location_picker.dart b/lib/src/location_picker.dart index 7919df5..8869a41 100644 --- a/lib/src/location_picker.dart +++ b/lib/src/location_picker.dart @@ -374,7 +374,7 @@ class _FlutterLocationPickerState extends State try { // Test if location services are enabled. // Position position = await Geolocator.getCurrentPosition(); - await checkLocationPermission(); + // await checkLocationPermission(); // return await location.getLocation(); return await Geolocator.getCurrentPosition(); } catch (e) {