noaa_nws_adapter 0.0.8
noaa_nws_adapter: ^0.0.8 copied to clipboard
NOAA / NWS direct-consume wrapper — smallest-slice GeoJSON client for api.weather.gov active winter alerts by point. Pure Dart.
// ignore_for_file: avoid_print
//
// Minimal runnable example for noaa_nws_adapter: fetch active U.S. winter
// alerts for a point and print them. NWS requires a User-Agent of the form
// "(yourapp.com, contact@email.com)"; the client raises ArgumentError
// up-front if omitted, so substitute your own contact.
import 'package:noaa_nws_adapter/noaa_nws_adapter.dart';
void main() async {
final client = NoaaNwsClient(userAgent: '(myapp.example.com, you@example.com)');
try {
// Active winter alerts near these coordinates (Grand Forks, ND).
final alerts = await client.fetchActiveWinterAlerts(
latitude: 47.9253,
longitude: -97.0329,
);
print('Active winter alerts: ${alerts.length}');
for (final a in alerts) {
print('• ${a.event} [${a.severity.name}] — ${a.headline}');
}
} on NoaaNwsHttpException catch (e) {
print('NWS unreachable: $e'); // honest failure; never a fake "all clear"
} finally {
client.close();
}
}