driving_weather library

Weather condition model and provider abstraction for driving applications.

Models precipitation, visibility, ice risk, and wind — the data a driving application needs to assess weather safety.

Three components:

  • WeatherCondition: Equatable model with precipitation type/intensity, temperature, visibility, wind speed, and ice risk.
  • WeatherProvider: Abstract interface — implement to plug any weather data source into a driving application.
  • OpenMeteoWeatherProvider: Concrete provider using the free Open-Meteo API with offline fallback (re-emits last known condition on failure).
  • SimulatedWeatherProvider: Demo provider generating a realistic mountain-pass snow scenario (clear → light → heavy → ice → clearing).

Safety: ASIL-QM — display and advisory only, no vehicle control.

import 'package:driving_weather/driving_weather.dart';

final provider = OpenMeteoWeatherProvider(
  latitude: 35.18,
  longitude: 136.91,
);
await provider.startMonitoring();
provider.conditions.listen((condition) {
  if (condition.isHazardous) {
    print('WARNING: ${condition.precipType.name} — ice=${condition.iceRisk}');
  }
});

Enums

PrecipitationIntensity
Intensity of precipitation.
PrecipitationType
Type of precipitation observed.

Exceptions / Errors

HttpException
Exception for HTTP errors from the Open-Meteo API.