You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dafl_music/Sources/dafl_project_flutter/lib/model/location.dart

23 lines
664 B

import 'package:geolocator/geolocator.dart';
import 'package:tuple/tuple.dart';
class Location {
static Future<Tuple2<double, double>> getCurrentLocation() async {
LocationPermission permission;
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.deniedForever) {
return Future.error('Location Not Available');
}
}
Position current = await Geolocator.getCurrentPosition();
double long = current.longitude;
double lat = current.latitude;
return Tuple2(long,lat);
}
}