This is the documentation for the Flutter package. Before integrating, read the native SDK documentation to familiarize yourself with the platform.
Add the package to your
Then, update dependencies:
Change to the
ios/ directory. In the
platform :ios, '10.0' or higher to your target.
On iOS, you must add location usage descriptions and background modes to your
Info.plist. Initialize the SDK in
AppDelegate.m, passing in your Radar publishable API key:
On Android, initialize the SDK in
MainApplication.java, passing in your Radar publishable API key:
First, import the package:
To identify the user when logged in, call:
userId is a stable unique ID for the user.
To set an optional dictionary of custom metadata for the user, call:
metadata is a map with up to 16 keys and values of type string, boolean, or number.
Finally, to set an optional description for the user, displayed in the dashboard, call:
description is a string.
You only need to call these functions once, as these settings will be persisted across app sessions.
Before tracking the user's location, the user must have granted location permissions for the app.
To determine the whether user has granted location permissions for the app, call:
status will be a string, one of:
To request location permissions for the app, call:
background is a boolean indicating whether to request background location permissions or foreground location permissions.
Once you have initialized the SDK and the user has granted permissions, you can track the user's location.
To track the user's location in the foreground, call:
On iOS and Android, once you have initialized the SDK and the user has granted permissions, you can start tracking the user's location in the background.
For background tracking, the SDK supports custom tracking options as well as three presets:
EFFICIENT: A low frequency of location updates and lowest battery usage. On Android, avoids Android vitals bad behavior thresholds.
RESPONSIVE: A medium frequency of location updates and low battery usage. Suitable for most consumer use cases.
CONTINUOUS: A high frequency of location updates and higher battery usage. Suitable for on-demand use cases (e.g., delivery tracking) and some consumer use cases (e.g., order ahead, "mall mode").
To start tracking the user's location in the background, call one of:
You only need to call these methods once, as these settings will be persisted across app sessions.
Though we recommend using presets for most use cases, you can customize the tracking options. See the tracking options reference.
To stop tracking the user's location in the background (e.g., when the user logs out), call:
On iOS and Android, you can simulate a sequence of location updates for testing. For example, to simulate a sequence of 10 location updates every 3 seconds by car from an
origin to a
destination, we can call:
On iOS and Android, to start a trip to a destination, call:
Later, to complete the trip and stop tracking, call:
Or, to cancel the trip and stop tracking, call:
Learn more about trip tracking.
You can manually update the user's location by calling:
The Flutter package also exposes APIs for anonymous context, geocoding, search, and distance.
Get a single location update without sending it to the server:
With the context API, get context for a location without sending device or user identifiers to the server:
With the forward geocoding API, geocode an address, converting address to coordinates:
With the reverse geocoding API, reverse geocode a location, converting coordinates to address:
With the IP geocoding API, geocode the device's current IP address, converting IP address to city, state, and country:
With the autocomplete API, autocomplete partial addresses and place names, sorted by relevance:
With the geofence search API, search for geofences near a location, sorted by distance:
With the places search API, search for places near a location, sorted by distance:
With the distance API, calculate the travel distance and duration from an origin to a destination:
Have questions? We're here to help! Email us at [email protected].