All Projects → worldturtlemedia → weather_icons

worldturtlemedia / weather_icons

Licence: MIT license
Flutter library for using erikflowers/weather-icons. An icon pack with over 200 weather icons.

Programming Languages

dart
5743 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to weather icons

Mahapps.metro.iconpacks
Awesome icon packs for WPF and UWP in one library
Stars: ✭ 1,157 (+9541.67%)
Mutual labels:  weather, icons
weather-styled-icon
⛅️☀️🌧🌨in ⚛️
Stars: ✭ 23 (+91.67%)
Mutual labels:  weather, icons
open-earth-compiler
development repository for the open earth compiler
Stars: ✭ 50 (+316.67%)
Mutual labels:  weather
weather-app-2020-android
Android Weather App 2020
Stars: ✭ 15 (+25%)
Mutual labels:  weather
tmux-weather
🌤 Weather plugin for tmux
Stars: ✭ 40 (+233.33%)
Mutual labels:  weather
Weather
用C#编写的天气预报小工具(.NET4.0 & Visual Studio 2017)
Stars: ✭ 19 (+58.33%)
Mutual labels:  weather
ArduinoWeatherOS
Arduino Uno, 433MhzRx and OS WMR86 Weather Station
Stars: ✭ 69 (+475%)
Mutual labels:  weather
yahoo-weather-java-api
A Java API for the yahoo weather service
Stars: ✭ 26 (+116.67%)
Mutual labels:  weather
WXKDarkSky
A pure-Swift Codable layer over the Dark Sky API.
Stars: ✭ 21 (+75%)
Mutual labels:  weather
MeteoalarmCard
Meteoalarm, Météo-France and DWD severe weather warnings card for Home Assistant Lovelace UI ⛈️
Stars: ✭ 48 (+300%)
Mutual labels:  weather
weather-icons
Free to use animated weather icons.
Stars: ✭ 341 (+2741.67%)
Mutual labels:  weather
Perfect-Weather
Demonstrate using URL Routes & variables, Fetching of remote data from API's as JSON, reading and transforming to data more appropriately consumable by an API client.
Stars: ✭ 32 (+166.67%)
Mutual labels:  weather
aerisjs
Aeris Interactive
Stars: ✭ 55 (+358.33%)
Mutual labels:  weather
ponyweather
Android weather app use rxjava&retrofit&material design
Stars: ✭ 79 (+558.33%)
Mutual labels:  weather
hs-weather
Weather menubar app for hammerspoon
Stars: ✭ 17 (+41.67%)
Mutual labels:  weather
WeatherRadar
An Android application featuring customizable, real-time doppler radar images
Stars: ✭ 35 (+191.67%)
Mutual labels:  weather
MMM-NOAA
Weather module
Stars: ✭ 17 (+41.67%)
Mutual labels:  weather
HexBot
A Relatively Simply Awesome Discord bot with Music, Games, Comics, Memes and other cool features. This bot is made in Python 3.8 using discord.py
Stars: ✭ 109 (+808.33%)
Mutual labels:  weather
1pone.github.io
Kindle拯救计划——一个Kindle实用工具网站,让你吃灰的Kindle成为时钟、天气看板、电子相册、微博热搜榜单...
Stars: ✭ 150 (+1150%)
Mutual labels:  weather
nuxt-weather
This weather app is just my sandbox to play with SSR and Nuxt.js ⛱️
Stars: ✭ 30 (+150%)
Mutual labels:  weather

weather_icons

A Flutter library for using Weather Icons.

CircleCI branch GitHub Coverage Status

Pub GitHub release GitHub commits since latest release

Note: All of the icon data is auto-generated based on the latest release of Weather Icons.

Installation

Add the dependency to your pubspec.yaml

dependencies:
  weather_icons: 2.0.x # Use the latest version

Null safety

To opt-in to the latest null-safe version use:

dependencies:
  weather_icons: 3.0.0-nullsafety.x # Use the latest version

Usage

The library exposes all of the Weather Icons as IconData. The naming convention is the same as the CSS names, minus the wi-, and all dashes replaced with underscores. It was named this way to match the default Icons class.

If you know which icon you need, you can use the provided constant icons. If you need a dynamic icon see below.

import 'package:flutter/material.dart';
import 'package:weather_icons/weather_icons.dart';

class MyWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return Icon(
      icon: BoxedIcon(WeatherIcons.day_sunny),
      onPressed: () {
          print("Foo");
      }
     );
  }
}

Note

Because of how the icons exist in the font file, there will be some display issues when using a standard Icon widget. The icon will draw outside of its boundaries causing issues with layouts and padding, etc.

You can see an example of this in the example/ application.

In order to overcome this, the library exposes a widget called BoxedIcon. Which puts the icon into a 'box' which properly sets its height, and width. Preventing any of the out of boundary drawing.

Anywhere you can use Icon, you can swap it out for BoxedIcon.

class MyWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return Icon(
      icon: BoxedIcon(WeatherIcons.day_sunny),
      onPressed: () {}
     );
  }
}

See weather_icons_g.dart for all of the icons.

Dynamic

If you need a dynamic icon at run-time, then you can use the included helper function for converting from the CSS style name to a IconData.

import 'package:flutter/material.dart';
import 'package:weather_icons/weather_icons.dart';

class WeatherDisplay extends StatelessWidget {
  final String weatherCode;

  WeatherDisplay(this.weatherCode);

  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          BoxedIcon(
            WeatherIcons.fromString(
                weatherCode,
                // Fallback is optional, throws if not found, and not supplied.
                fallback: WeatherIcons.na
            ),
          ),
          Text("Icon for '$weatherCode'"),
        ],
      ),
    );
  }
}

Wind Direction

The wind icon is a special icon, as it is one single icon value that is then rotated using CSS. To achieve a similar functionality you can use the WindIcon class.

The WindIcon's always use BoxedIcon.

Note: This means that WeatherIcons.wind will always be the North facing icon.

import 'package:flutter/material.dart';
import 'package:weather_icons/weather_icons.dart';

class EastlyWindWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return IconButton(
      // Display a Wind icon facing towards east
      icon: WindIcon.towards_e,
      onPressed: () { ... }
     );
  }
}

Since the Weather Icons support both 'towards' and 'from' wind directions, this library does as well.

Dynamic Wind Direction

Just like the weather above, if your wind direction is dynamic you can create your own WindIcon.

import 'package:flutter/material.dart';
import 'package:weather_icons/weather_icons.dart';

class WindDirectionDisplay extends StatelessWidget {
  final double windDirectionDegree;

  WindDirectionDisplay(this.windDirectionDegree);

  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          WindIcon(degree: windDirectionDegree),
          Text("Icon for wind @ $windDirectionDegree°"),
        ],
      ),
    );
  }
}

Note: The degree must be within the degrees of a compass/circle, so 0-360.

Time icons

weather_icons also includes a helper for displaying the time icons.

// Manual hour
IconButton(
  icon: BoxedIcon(TimeIcon.iconFromHour(3)),
  onPressed: () { print("Displaying the third hour!"); }
);

// Using a DateTime instance
IconButton(
  icon: BoxedIcon(TimeIcon.iconFromDate(DateTime.now())),
  onPressed: () { print("Current hour"); }
);

// Creating your own Icon
BoxedIcon(
  icon: TimeIcon.fromHour(3),
  size: 60,
)

// Also using a DateTime
BoxedIcon(
  icon: TimeIcon.fromDate(DateTime.now()),
  size: 60,
)

Example

A full example can be found in the example folder.

TODO

  • Add support for the weather service mappings here

Contributing

See CONTRIBUTING

License

MIT License

Copyright (c) 2019 WorldTurtleMedia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].