Geofence constructor

Geofence({
  1. required String identifier,
  2. double? radius,
  3. double? latitude,
  4. double? longitude,
  5. bool? notifyOnEntry,
  6. bool? notifyOnExit,
  7. bool? notifyOnDwell,
  8. int? loiteringDelay,
  9. Map<String, dynamic>? extras,
  10. List<List<double>>? vertices,
})

Implementation

Geofence(
    {required String identifier,
    double? radius,
    double? latitude,
    double? longitude,
    bool? notifyOnEntry,
    bool? notifyOnExit,
    bool? notifyOnDwell,
    int? loiteringDelay,
    Map<String, dynamic>? extras,
    List<List<double>>? vertices}) {
  if (vertices == null) {
    // Circular Geofence
    if (radius == null || latitude == null || longitude == null) {
      throw ArgumentError("Geofence requires radius, latitude and longitude");
    }
  } else {
    // Polygon Geofence
    this.vertices = vertices;
  }
  if (radius != null) this.radius = radius * 1.0;
  if (latitude != null) this.latitude = latitude * 1.0;
  if (longitude != null) this.longitude = longitude * 1.0;

  this.identifier = identifier;
  this.notifyOnEntry = notifyOnEntry;
  this.notifyOnExit = notifyOnExit;
  this.notifyOnDwell = notifyOnDwell;
  this.loiteringDelay = loiteringDelay;
  this.extras = extras;
}