updateSpeed method

void updateSpeed(
  1. double speed
)

Updates the current speed

Implementation

void updateSpeed(double speed) {
  debugPrint("[DEBUG] GPS speed updated: $speed km/h at ${DateTime.now()}");
  final previousSpeed = _currentSpeed;
  _currentSpeed = speed;

  // Get speed limit for current location if available
  final currentLimit = speedLimit;
  if (currentLimit != null) {
    debugPrint("[DEBUG] Speed limit updated: $currentLimit km/h at ${DateTime.now()}");

    // Log speed status
    final status = speedStatus;
    if (status == SpeedStatus.warning) {
      debugPrint("[DEBUG] WARNING: Speed is slightly over the limit (${((speed/currentLimit)-1)*100}% over)");
    } else if (status == SpeedStatus.danger) {
      debugPrint("[DEBUG] DANGER: Speed is significantly over the limit (${((speed/currentLimit)-1)*100}% over)");
    }
  }

  // Only notify if speed has changed significantly to reduce updates
  if ((previousSpeed - speed).abs() > 1.0) {
    notifyListeners();
  }
}