ULocation class abstract final

GPS position, live tracking, permissions, geofences, compass and addresses on all 6 platforms, no Google Play Services. Needs dart run u:app permission add location. final UPosition? p = await ULocation.position();

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

addGeofence(UGeofence fence) → Future<bool>
Watches a circle; enter/exit works in the background on Android, iOS, macOS, Windows; Linux/web only while the app runs. ULocation.addGeofence(UGeofence(id: "home", latitude: 35.7, longitude: 51.4, radius: 200)) · background: permission add location-always
addressOf(double latitude, double longitude, {String? locale}) → Future<List<UPlacemark>>
Street address of a point, in locale (Android, iOS, macOS; empty elsewhere). (await ULocation.addressOf(35.7, 51.4)).first.street
bearing(double lat1, double lng1, double lat2, double lng2) → double
Direction in degrees (0 = north) from point 1 to point 2. ULocation.bearing(lat1, lng1, lat2, lng2)
clearGeofences() → Future<void>
Stops watching every area.
current({ULocationAccuracy accuracy = ULocationAccuracy.high, Duration timeout = const Duration(seconds: 20), Duration? maxAge}) → Future<ULocationResult>
Current position, asking for permission when needed; on failure .error says why (denied, GPS off, timeout…). Web: HTTPS only. final r = await ULocation.current(); if (r.position != null) …
distance(double lat1, double lng1, double lat2, double lng2) → double
Distance in metres between two points (pure math, any platform). ULocation.distance(35.7, 51.4, 32.6, 51.6)
ensureReady({bool always = false}) → Future<ULocationError?>
Asks if needed; returns null when location is usable, else the reason (show a message or open settings). final err = await ULocation.ensureReady(); if (err != null) …
find(String address, {String? locale}) → Future<List<UPlacemark>>
Coordinates of an address text (Android, iOS, macOS; empty elsewhere). await ULocation.find("Azadi Tower, Tehran")
geofenceEvents() → Stream<UGeofenceEvent>
Enter/exit events, including ones that happened while the app was closed. ULocation.geofenceEvents().listen((e) => UNotification.show(1, title: "Welcome home"))
geofences() → Future<List<UGeofence>>
Every area being watched.
heading() → Stream<UHeading>
Compass direction while you listen: Android, iOS, Windows with a compass, mobile web; not macOS/Linux. ULocation.heading().listen((h) => angle = h.degrees)
isGeocodingAvailable() → Future<bool>
True when addressOf / find work on this device.
isReady() → Future<bool>
True when permission is granted and location services are on.
isServiceEnabled() → Future<bool>
True when the device's location switch is on.
lastKnown() → Future<UPosition?>
Last position the OS remembers, instantly; may be old or null (web and Linux: null). ULocation.lastKnown()
openAppSettings() → Future<bool>
Opens this app's settings to grant a permission that was denied forever (web: false). ULocation.openAppSettings()
openLocationSettings() → Future<bool>
Opens the system location settings so the user can turn GPS on (web: false). ULocation.openLocationSettings()
permission() → Future<ULocationPermission>
Permission state, precise vs approximate, and whether the GPS switch is on. (await ULocation.permission()).isGranted
position({ULocationAccuracy accuracy = ULocationAccuracy.high}) → Future<UPosition?>
Current position, or null when it cannot be read (use current() to know why). final UPosition? p = await ULocation.position();
removeGeofence(String id) → Future<void>
Stops watching one area. ULocation.removeGeofence("home")
requestPermission({bool always = false}) → Future<ULocationPermission>
Asks for location permission; always also asks for background access (Android/iOS/macOS). await ULocation.requestPermission()
requestPrecise(String purposeKey) → Future<bool>
iOS 14+ only: asks to upgrade approximate to precise; purposeKey from NSLocationTemporaryUsageDescriptionDictionary. ULocation.requestPrecise("Delivery")
stream([ULocationSettings settings = const ULocationSettings()]) → Stream<UPosition>
Live positions while you listen; background: true keeps going in the background (Android/iOS, needs permission add location-always). ULocation.stream(const ULocationSettings(distanceFilter: 10)).listen(update)
visits() → Stream<UVisit>
iOS only: places the user arrives at and leaves (battery friendly). ULocation.visits().listen(logVisit)