getCurrentPosition method

Future<Position> getCurrentPosition({
  1. LocationAccuracy desiredAccuracy = LocationAccuracy.best,
  2. bool forceAndroidLocationManager = false,
  3. Duration? timeLimit,
})

Returns the current position taking the supplied desiredAccuracy into account.

Calling the getCurrentPosition method will request the platform to obtain a location fix, depending on the availability of different location services this can take several seconds. The recommended use would be to call the getLastKnownPosition method to receive a cached position and update it with the result of the getCurrentPosition method.

On Android you can force the use of the Android LocationManager instead of the FusedLocationProvider by setting the forceAndroidLocationManager parameter to true. The timeLimit parameter allows you to specify a timeout interval (by default no time limit is configured).

Throws a TimeoutException when no location is received within the supplied timeLimit duration. Throws a PermissionDeniedException when trying to request the device's location when the user denied access. Throws a LocationServiceDisabledException when the user allowed access, but the location services of the device are disabled.

Implementation

Future<Position> getCurrentPosition({
  LocationAccuracy desiredAccuracy = LocationAccuracy.best,
  bool forceAndroidLocationManager = false,
  Duration? timeLimit,
}) {
  throw UnimplementedError('getCurrentPosition() has not been implemented.');
}