getCurrentGeolocation static method

Future<Geolocation> getCurrentGeolocation()

Implementation

static Future<Geolocation> getCurrentGeolocation() async {
  print('Geolocation.getCurrentGeolocation> ...');
  var geolocation = window.navigator.geolocation;
  var currentPosition = await geolocation.getCurrentPosition(
      enableHighAccuracy: true,
      timeout: Duration(seconds: 30),
      maximumAge: Duration(minutes: 10));
  print('Geolocation.getCurrentGeolocation> $currentPosition');
  var coords = currentPosition.coords!;
  return Geolocation(coords.latitude!, coords.longitude!);
}