addGeofence method

Future<bool> addGeofence(
  1. String id,
  2. double lat,
  3. double lon,
  4. double radius,
)

Adds a virtual circular boundary trigger at the specified coordinates.

Triggers will be handled by the background intelligence system.

Implementation

Future<bool> addGeofence(String id, double lat, double lon, double radius) {
  if (id.trim().isEmpty) {
    throw ArgumentError.value(id, 'id', 'Geofence id cannot be empty.');
  }
  if (lat < -90 || lat > 90) {
    throw ArgumentError.value(lat, 'lat', 'Must be between -90 and 90.');
  }
  if (lon < -180 || lon > 180) {
    throw ArgumentError.value(lon, 'lon', 'Must be between -180 and 180.');
  }
  if (radius <= 0) {
    throw ArgumentError.value(radius, 'radius', 'Must be greater than zero.');
  }
  return NexoraSdkPlatform.instance.addGeofence(id, lat, lon, radius);
}