Finding Location

Get current location finds where the person is, once, and hands it to the next step: show events near them, fill in a pickup point, or record where a report was made. One design works on iOS, Android and the web.

Adding it

Add Get current location to a button and fill in:

AccuracyPrecise, or approximate: about a kilometre, enough for a city or a neighbourhood, faster and kinder to the battery. Keep it precise for anything shown on a map.
Result nameWhat the next steps call the position, such as here.
On successWhat runs once the position is found.
On errorWhat runs when no position comes within 15 seconds, or the device fails. Without it, the app says it could not find the location.
On deniedWhat runs when location is refused, or switched off on the device, as on the Asking for Permission page.

Using the position

The result has three numbers: latitude, longitude and accuracy, how sure the device is, in metres. Pick them in the data picker anywhere after it: a screen parameter, a record's values, a message.

a report, where it was made
text
Get current location   Accuracy: precise, Result name: here
  On success           Create a report with latitude = here → latitude,
                       longitude = here → longitude
  On error             Show "We couldn't find you. Try again outside."

Always fresh, one at a time

It never hands back an old position, and it does not follow the person around: one tap, one position. If the person allowed only approximate location (iPhone's Precise Location off, or Android's approximate), the position still comes back, and its accuracy says how rough it is.

Asking

Location is asked for first, exactly as Ask for permission does, so there is never an Ask for permission in front of it. Refused, On denied runs with the reason; location switched off on the device is unavailable. iOS shows your Location message from App, Permission messages.

What each export uses

Flutter. geolocator for the position; asking stays with permission_handler.

Expo. expo-location.

Web. The browser's own geolocation. A browser that has been refused once will not ask again, so there the reason is blocked.

Trying it

In Preview there is no position: it uses a fixed one, Accra, and says so, then runs On success. On a device, try it once indoors and once outside; to check the refused case, turn location off for the app in Settings first.