28 lines
983 B
Dart
28 lines
983 B
Dart
import 'package:geolocator/geolocator.dart';
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
LatLng? latlong;
|
|
|
|
getLocation() async {
|
|
LocationPermission permission = await Geolocator.checkPermission();
|
|
|
|
if (permission == LocationPermission.denied ||
|
|
permission == LocationPermission.deniedForever) {
|
|
permission = await Geolocator.requestPermission();
|
|
// } else {
|
|
Position currentP = await Geolocator.getCurrentPosition(
|
|
desiredAccuracy: LocationAccuracy.best);
|
|
latlong = LatLng(currentP.latitude, currentP.longitude);
|
|
} else {
|
|
// Position currentP = await Geolocator.getCurrentPosition(
|
|
// desiredAccuracy: LocationAccuracy.best);
|
|
// latlong = LatLng(prefs.getDouble('lat')!, prefs.getDouble('long')!);
|
|
Position currentP = await Geolocator.getCurrentPosition(
|
|
desiredAccuracy: LocationAccuracy.best);
|
|
latlong = LatLng(currentP.latitude, currentP.longitude);
|
|
}
|
|
print(latlong);
|
|
print('done');
|
|
}
|
|
|