lastKnownLocation method

Future<LocationResult> lastKnownLocation ({LocationPermission permission: const LocationPermission() })

Retrieves the most recent Location currently available. Automatically request location permission beforehand if not granted.

It does not request the device to fetch a new location, but returns the last cached location. Location is not guaranteed to be available, and request will fail with GeolocationResultErrorType.locationNotFound otherwise. This method is reliable to get a one-shot current location on Android, but not so much on iOS.

See also:

Implementation

static Future<LocationResult> lastKnownLocation({
  LocationPermission permission = const LocationPermission(),
}) =>
    _locationChannel.lastKnownLocation(permission);