driving_weather 0.1.2
driving_weather: ^0.1.2 copied to clipboard
Weather condition model for driving applications — snow, ice, visibility, and hazardous conditions detection. Precipitation type/intensity, wind speed, ice risk, and temperature monitoring. Includes O [...]
driving_weather #
Weather condition model and provider abstraction for driving applications.
Features #
- WeatherCondition — Equatable model with precipitation type/intensity, temperature, visibility, wind speed, and ice risk
- WeatherProvider — Abstract interface for pluggable weather data sources
- OpenMeteoWeatherProvider — Real weather from Open-Meteo (free, no API key) with offline fallback
- SimulatedWeatherProvider — Demo provider with a realistic mountain-pass snow scenario
Install #
dependencies:
driving_weather: ^0.1.2
Usage #
import 'package:driving_weather/driving_weather.dart';
// Real weather from Open-Meteo (Nagoya region default)
final provider = OpenMeteoWeatherProvider(
latitude: 35.18,
longitude: 136.91,
);
await provider.startMonitoring();
provider.conditions.listen((condition) {
print('${condition.precipType.name} ${condition.intensity.name}');
print('Visibility: ${condition.visibilityMeters}m');
if (condition.isHazardous) {
print('⚠ Hazardous conditions detected');
}
if (condition.iceRisk) {
print('⚠ Ice risk — temperature: ${condition.temperatureCelsius}°C');
}
});
Simulated weather (for demos and testing) #
final sim = SimulatedWeatherProvider(
interval: Duration(seconds: 5),
);
await sim.startMonitoring();
// Cycles: clear → light snow → moderate → heavy → ice → clearing
Custom weather source #
class MyFleetWeatherProvider implements WeatherProvider {
// Implement the 4 methods: conditions, startMonitoring,
// stopMonitoring, dispose
}
API Overview #
| Type | Purpose |
|---|---|
WeatherCondition |
Snapshot of precipitation, temperature, visibility, wind, and ice risk. |
WeatherProvider |
Abstract interface for live or simulated weather sources. |
OpenMeteoWeatherProvider |
Pulls real weather data with offline fallback behavior. |
SimulatedWeatherProvider |
Provides deterministic demo and test weather sequences. |
Model #
| Field | Type | Description |
|---|---|---|
precipType |
PrecipitationType |
none, rain, snow, sleet, hail |
intensity |
PrecipitationIntensity |
none, light, moderate, heavy |
temperatureCelsius |
double |
Temperature in °C |
visibilityMeters |
double |
10000 = clear, <1000 = reduced, <200 = hazardous |
windSpeedKmh |
double |
Wind speed |
iceRisk |
bool |
Black ice / road icing risk |
timestamp |
DateTime |
Observation time |
Convenience getters #
isSnowing— snow at any intensityhasReducedVisibility— visibility < 1 kmisHazardous— heavy precip, very low visibility, or iceisFreezing— temperature ≤ 0°C
Safety #
ASIL-QM — display and advisory only. Not for vehicle control.
See Also #
- kalman_dr — Dead reckoning through GPS loss (tunnels, urban canyons)
- routing_engine — Engine-agnostic routing (OSRM + Valhalla)
- driving_consent — Privacy consent with Jidoka semantics (UNKNOWN = DENIED)
- fleet_hazard — Fleet telemetry hazard model and geographic clustering
- driving_conditions — Pure Dart computation models for road surface, visibility, and safety score simulation
- navigation_safety — Flutter navigation safety state machine and safety overlay
- map_viewport_bloc — Flutter viewport and layer composition state machine
- routing_bloc — Flutter route lifecycle state machine and progress UI
- offline_tiles — Flutter offline tile manager with MBTiles fallback
All ten extracted packages are part of SNGNav, a driver-assisting navigation reference product.