和风天气插件
A qweather flutter plugin.
- 实时天气查询
- 逐天天气查询
- 逐时天气查询
- 中国地区未来2小时内每5分钟降水查询
- 其他功能...
由于平时比较忙,计划每天增加一个接口。
首先你得有个和风天气的账号,去吧骚年。账号注册成功后在应用管理创建应用。注意包名别写错了哦。
Android:com.fluttercandies.flutter_qweather_example
ios: com.fluttercandies.flutterQweatherExample
QweatherConfig config = QweatherConfig(
publicIdForAndroid: 'HE210xxxxxxxxxxxxx',
keyForAndroid: '8453863xxxxxxxxxxxxxxxxxxxxxxxxxx',
publicIdForIos: 'HE210xxxxxxxxxxxxx',
keyForIos: 'aead742xxxxxxxxxxxxxxxxxxxxxxxxx',
biz: false,
debug: true);
await FlutterQweather.instance.init(config);
location 为 LocationID 或者 经纬度; LocationID 可通过geo 接口查询 或 查看https://github.com/qwd/LocationList
String location = '116.41,39.92';
WeatherNow? _resp = await FlutterQweather.instance.getWeatherNow(location);
String location = '116.41,39.92';
WeatherDailyResp? _resp = await FlutterQweather.instance.getWeatherDaily(location, WeatherDailyForecast.WeatherForecast3Day);
String location = '116.41,39.92';
WeatherHourlyResp? _resp = await FlutterQweather.instance.getWeatherHourly(location, WeatherHourlyForecast.WeatherForecast24Hour);
String location = '116.41,39.92';
WeatherMinutelyResp? _resp = await FlutterQweather.instance.getWeatherMinuteLy(location);
只打包了安卓app-release.apk,ios 请自行运行 example
目前仅实现了查询实时天气(很短时间写的东西,别指望我写多少😂),其他接口后续慢慢加上。
第一次写跟原生交互的插件,望各位大大多多指点,有写得不好的地方,请直接用 PR 来怼我。