processLocation method

void processLocation(
  1. Location location
)

Processes a location update.

Call this with each location to check if it represents a significant change.

Implementation

void processLocation(Location location) {
  if (!_isMonitoring || _config == null) return;

  // First location - store and potentially emit
  if (_lastLocation == null) {
    _lastLocation = location;
    if (!_config!.deferUntilMoved) {
      _emitChange(location, wasTimerTriggered: false);
    }
    return;
  }

  // Calculate displacement
  final displacement = LocationUtils.calculateDistance(
    _lastLocation!.coords,
    location.coords,
  );

  // Check if significant
  if (displacement >= _config!.minDisplacementMeters) {
    _emitChange(
      location,
      displacement: displacement,
      wasTimerTriggered: false,
    );
    _lastLocation = location;
  }
}