weather_svg_icons 0.3.0
weather_svg_icons: ^0.3.0 copied to clipboard
Static and animated SVG weather icons for Flutter, with WMO code mapping and an Icon-style widget API.
Weather SVG Icons #
A Flutter package for displaying static and animated weather SVG icons with an
API similar to Flutter's Icon widget. It includes WMO weather-code mapping,
day and night variants, and a typed icon catalog.
Features #
- Use familiar constants such as
WeatherSvgIcons.rain. - Access all 519 bundled icons through typed
WeatherSvgIcons.*constants. - Select icons directly from WMO weather interpretation codes.
- Switch between static and animated SVG variants with one parameter.
- Use the same API on Android, iOS, Linux, macOS, web, and Windows.
Installation #
Add the package to your pubspec.yaml:
dependencies:
weather_svg_icons: ^0.3.0
Then fetch the dependency:
flutter pub get
Usage by WMO code #
import 'package:weather_svg_icons/weather_svg_icons.dart';
WeatherSvgIcon.byCode(
61,
isDay: true,
animated: true,
size: 32,
);
isDay selects the appropriate day or night variant for codes that support
both.
Usage with an icon constant #
Use an icon constant similarly to Flutter's Icon widget:
WeatherSvgIcon(
WeatherSvgIcons.rain,
isDay: true,
animated: true,
size: 32,
);
Every static icon in the package has a lower-camel-case constant. Asset names are converted directly, for example:
WeatherSvgIcons.partlyCloudyDayRain // partly-cloudy-day-rain.svg
WeatherSvgIcons.thermometerCelsius // thermometer-celsius.svg
WeatherSvgIcons.windBeaufort10 // wind-beaufort-10.svg
When an animated variant is unavailable, animated: true safely falls back to
the static SVG.
Available options #
| Parameter | Default | Description |
|---|---|---|
isDay |
true |
Selects day or night variants when using WeatherSvgIcon.byCode. |
animated |
false |
Uses the animated SVG asset. |
size |
null |
Sets both width and height. |
width / height |
null |
Sets dimensions independently when size is not provided. |
fit |
BoxFit.contain |
Controls how the SVG fits its bounds. |
colorFilter |
null |
Applies a color filter where supported by the renderer. |
placeholder |
null |
Displays a widget while a native or static SVG is loading. |
semanticsLabel |
icon name | Provides an accessibility label. |
Supported WMO codes #
| Codes | Condition |
|---|---|
0 |
Clear sky |
1 |
Mainly clear |
2 |
Partly cloudy |
3 |
Overcast |
45, 48 |
Fog |
51, 53, 55 |
Drizzle |
56, 57, 66, 67 |
Freezing drizzle or rain / sleet |
61, 63, 65 |
Rain |
71, 73, 75, 77 |
Snow |
80, 81, 82 |
Rain showers |
85, 86 |
Snow showers |
95 |
Thunderstorm |
96, 99 |
Thunderstorm with hail |
Unknown codes use WeatherSvgIcons.notAvailable.
Platform behavior #
Static icons are rendered with flutter_svg. Animated icons use
full_svg_flutter on native platforms and the browser's SVG rendering on web.
Attribution #
The bundled weather SVG assets are based on Meteocons by Bas Milius and are distributed under the MIT License. See LICENSE for the complete notices.
License #
This package is available under the MIT License.