diff --git a/lib/src/location_picker.dart b/lib/src/location_picker.dart index 65d712b..8869a41 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. - await checkLocationPermission(); - return await location.getLocation(); + // Position position = await Geolocator.getCurrentPosition(); + // await checkLocationPermission(); + // 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