├── .gitignore ├── .gradle ├── 5.2.1 │ ├── fileChanges │ │ └── last-build.bin │ ├── fileHashes │ │ └── fileHashes.lock │ └── gc.properties ├── buildOutputCleanup │ ├── buildOutputCleanup.lock │ └── cache.properties └── vcs-1 │ └── gc.properties ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── libraries │ ├── Dart_SDK.xml │ └── Flutter_Plugins.xml ├── misc.xml ├── modules.xml ├── runConfigurations │ └── example_lib_main_dart.xml └── vcs.xml ├── .metadata ├── CHANGELOG.md ├── CHANGELOG_ZH.md ├── LICENSE ├── README.md ├── README_ZH.md ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── flutter_weather_bg_example │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ ├── anim_view.dart │ ├── grid_view.dart │ ├── list_view.dart │ ├── main.dart │ └── page_view.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── flutter_weather_bg.iml ├── images ├── cloud.webp ├── lightning0.webp ├── lightning1.webp ├── lightning2.webp ├── lightning3.webp ├── lightning4.webp ├── rain.webp ├── snow.webp └── sun.webp ├── lib ├── bg │ ├── weather_bg.dart │ ├── weather_cloud_bg.dart │ ├── weather_color_bg.dart │ ├── weather_night_star_bg.dart │ ├── weather_rain_snow_bg.dart │ └── weather_thunder_bg.dart ├── flutter_weather_bg.dart └── utils │ ├── image_utils.dart │ ├── print_utils.dart │ └── weather_type.dart ├── pubspec.lock ├── pubspec.yaml └── test └── flutter_weather_bg_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | .idea/ 9 | android/ 10 | ios/ -------------------------------------------------------------------------------- /.gradle/5.2.1/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gradle/5.2.1/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/.gradle/5.2.1/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /.gradle/5.2.1/gc.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/.gradle/5.2.1/gc.properties -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/buildOutputCleanup.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/.gradle/buildOutputCleanup/buildOutputCleanup.lock -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Thu Sep 17 09:45:43 CST 2020 2 | gradle.version=5.2.1 3 | -------------------------------------------------------------------------------- /.gradle/vcs-1/gc.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/.gradle/vcs-1/gc.properties -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 30 | 31 | 53 | 54 | 55 | 57 | 58 | 59 | 61 | 62 | 63 |
64 | 65 | 66 | 67 | xmlns:android 68 | ^$ 69 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | 77 | xmlns:.* 78 | ^$ 79 | 80 | 81 | BY_NAME 82 | 83 |
84 |
85 | 86 | 87 | 88 | .*:id 89 | http://schemas.android.com/apk/res/android 90 | 91 | 92 | 93 |
94 |
95 | 96 | 97 | 98 | .*:name 99 | http://schemas.android.com/apk/res/android 100 | 101 | 102 | 103 |
104 |
105 | 106 | 107 | 108 | name 109 | ^$ 110 | 111 | 112 | 113 |
114 |
115 | 116 | 117 | 118 | style 119 | ^$ 120 | 121 | 122 | 123 |
124 |
125 | 126 | 127 | 128 | .* 129 | ^$ 130 | 131 | 132 | BY_NAME 133 | 134 |
135 |
136 | 137 | 138 | 139 | .*:layout_width 140 | http://schemas.android.com/apk/res/android 141 | 142 | 143 | 144 |
145 |
146 | 147 | 148 | 149 | .*:layout_height 150 | http://schemas.android.com/apk/res/android 151 | 152 | 153 | 154 |
155 |
156 | 157 | 158 | 159 | .*:layout_.* 160 | http://schemas.android.com/apk/res/android 161 | 162 | 163 | BY_NAME 164 | 165 |
166 |
167 | 168 | 169 | 170 | .*:width 171 | http://schemas.android.com/apk/res/android 172 | 173 | 174 | BY_NAME 175 | 176 |
177 |
178 | 179 | 180 | 181 | .*:height 182 | http://schemas.android.com/apk/res/android 183 | 184 | 185 | BY_NAME 186 | 187 |
188 |
189 | 190 | 191 | 192 | .* 193 | http://schemas.android.com/apk/res/android 194 | 195 | 196 | BY_NAME 197 | 198 |
199 |
200 | 201 | 202 | 203 | .* 204 | .* 205 | 206 | 207 | BY_NAME 208 | 209 |
210 |
211 |
212 |
213 |
214 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/Flutter_Plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations/example_lib_main_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: bbfbf1770cca2da7c82e887e4e4af910034800b6 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.8.0 2 | 3 | - Optimize the distance effect of raindrops 4 | - Optimize the display effect under different width and height 5 | - Optimize rendering logic 6 | 7 | ## 2.7.0 8 | 9 | - Beautify the home page entrance display UI 10 | 11 | ## 2.6.0 12 | 13 | - Minimum height of restricted sunny night 14 | 15 | ## 2.5.0 16 | 17 | - Update ReadMe 18 | 19 | ## 2.3.0 20 | 21 | - Add comment information 22 | 23 | ## 2.2.0 24 | 25 | - Adjust cloud image position 26 | - Remove unnecessary printing 27 | - New list display example 28 | 29 | ## 2.1.0 30 | 31 | - Remove unnecessary tripartite dependence 32 | - Support multi platform 33 | 34 | ## 2.0.0 35 | 36 | - Add more detailed comments and instructions 37 | - Supports over animation when switching weather types 38 | - Support the display effect of pictures after dynamically changing the width and height 39 | - Optimized rendering algorithm, more fluent 40 | 41 | ## 1.3.0 42 | 43 | - Add comments; change code structure 44 | 45 | ## 1.2.0 46 | 47 | - Update Readme 48 | 49 | ## 1.1.0 50 | 51 | - Support dynamic modification of background size, and optimize cloud image effect 52 | 53 | ## 1.0.0 54 | 55 | - The basic functions are completed and 15 weather background types are supported 56 | 57 | ## 0.0.3 58 | 59 | - Update Readme 60 | 61 | ## 0.0.2 62 | 63 | - Add test widget and test plug-in 64 | 65 | ## 0.0.1 66 | 67 | * Init project 68 | 69 | 70 | -------------------------------------------------------------------------------- /CHANGELOG_ZH.md: -------------------------------------------------------------------------------- 1 | ## 2.8.0 2 | 3 | - 优化雨滴的远近效果 4 | - 优化不同宽高下的展示效果 5 | - 优化绘制逻辑 6 | 7 | ## 2.7.0 8 | 9 | - 美化首页入口展示 UI 10 | 11 | ## 2.6.0 12 | 13 | - 限制晴晚的最小高度 14 | 15 | ## 2.5.0 16 | 17 | - 更新 ReadMe 18 | 19 | ## 2.3.0 20 | 21 | - 添加注释信息 22 | 23 | ## 2.2.0 24 | 25 | - 调整云图位置 26 | - 去除不必要打印 27 | - 新增列表展示例子 28 | 29 | ## 2.1.0 30 | 31 | - 去除不必要的三方依赖 32 | - 支持多平台 33 | 34 | ## 2.0.0 35 | 36 | - 添加更加详细的注释和说明 37 | - 支持切换天气类型时的过度动画 38 | - 支持动态更改宽高后,图片的展示效果 39 | - 优化绘制算法,更加流畅 40 | 41 | ## 1.3.0 42 | 43 | - 添加注释;更改代码结构 44 | 45 | ## 1.2.0 46 | 47 | - 更新 readme 48 | 49 | ## 1.2.0 50 | 51 | - 更新 readme 52 | 53 | ## 1.1.0 54 | 55 | - 支持动态修改背景尺寸,并且优化云图效果 56 | 57 | ## 1.0.0 58 | 59 | - 基础功能完成,支持15中天气背景类型 60 | 61 | ## 0.0.3 62 | 63 | - 更新 readme 64 | 65 | ## 0.0.2 66 | 67 | - 添加测试 widget,测试插件 68 | 69 | ## 0.0.1 70 | 71 | * 初始项目 72 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Vladimir Kharlampidi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_weather_bg 2 | 3 | [![Pub Version](https://img.shields.io/pub/v/flutter_weather_bg?style=plastic)](https://pub.flutter-io.cn/packages/flutter_weather_bg) 4 | 5 | A rich and cool weather dynamic background plug-in, supporting 15 weather types. [README_ZH](https://github.com/xiaweizi/flutter_weather_bg/blob/master/README_ZH.md) 6 | 7 | **Use this plug-in to complete the weather background animation effect in my own project [SimplicityWeather](https://github.com/xiaweizi/SimplicityWeather) .** 8 | **If you want to experience it, please [click the download link](http://xiaweizi.top/SimplicityWeather-2_6.apk) to download it** 9 | 10 | ## Features 11 | 12 | - It supports 15 weather types: sunny, sunny evening, cloudy, cloudy evening, overcast, small to medium heavy rain, small to medium heavy snow, fog, haze, floating dust and thunderstorm 13 | - Support dynamic scale size, adapt to multi scene display 14 | - Supports over animation when switching weather types 15 | 16 | ## Supported platforms 17 | 18 | - Flutter Android 19 | - Flutter iOS 20 | - Flutter web 21 | - Flutter desktop 22 | 23 | ## Installation 24 | 25 | Add `flutter_weather_bg: ^2.8.0` to your `pubspec.yaml` dependencies. And import it: 26 | 27 | ```dar 28 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 29 | ``` 30 | 31 | ## How to use 32 | 33 | To configure the weather type by creating `WeatherBg`, you need to pass in the width and height to complete the final display 34 | 35 | ```dart 36 | WeatherBg(weatherType: _weatherType,width: _width,height: _height,) 37 | ``` 38 | 39 | ## Preview 40 | 41 | Regular `pageview` display effect 42 | 43 | ![home](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/92cbc9dbbd19419793ffec0e9f04457b~tplv-k3u1fbpfcp-zoom-1.image) 44 | 45 | 46 | 47 | List `listview` display effect 48 | 49 | ![list](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e6076f6ca3af4d3a8778313006ab9663~tplv-k3u1fbpfcp-zoom-1.image) 50 | 51 | 52 | 53 | The grid` GridView`displays the effect and supports the dynamic switching of the grid number 54 | 55 | ![check](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/d2e396e151764a7e8f86e798282833b9~tplv-k3u1fbpfcp-zoom-1.image) 56 | 57 | 58 | Dynamic reduction example demonstration 59 | 60 | ![width_height](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c8a4002423db4b77b0d2374f6da1c055~tplv-k3u1fbpfcp-zoom-1.image) 61 | 62 | 63 | 64 | Toggle weather type transition animation 65 | 66 | ![check](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5c4e75165cbb4a87b8176baa636c432d~tplv-k3u1fbpfcp-zoom-1.image) 67 | 68 | 69 | 70 | ## License 71 | 72 | MIT -------------------------------------------------------------------------------- /README_ZH.md: -------------------------------------------------------------------------------- 1 | # flutter_weather_bg 2 | 3 | [![Pub Version](https://img.shields.io/pub/v/flutter_weather_bg?style=plastic)](https://pub.flutter-io.cn/packages/flutter_weather_bg) 4 | 5 | 一款丰富炫酷的天气动态背景插件,支持 **15** 种天气类型。 6 | 7 | **在自己做的项目 [简悦天气](https://github.com/xiaweizi/SimplicityWeather) 中使用此插件完成天气背景动画效果。** 8 | 9 | **如果想体验请点击[下载链接](http://xiaweizi.top/SimplicityWeather-2_6.apk)下载** 10 | 11 | ## 功能 12 | 13 | - 支持 **15** 种 天气类型:晴、晴晚、多云、多云晚、阴、小中大雨、小中大雪、雾、霾、浮尘和雷暴 14 | - 支持 动态缩放尺寸,适配多场景下展示 15 | - 支持 切换天气类型时过度动画 16 | 17 | ## 支持的平台 18 | 19 | - Flutter Android 20 | - Flutter iOS 21 | - Flutter web 22 | - Flutter desktop 23 | 24 | ## 安装 25 | 26 | 添加 `flutter_weather_bg: ^2.7.0` 到 `pubspec.yaml` 文件中,并且导包: 27 | 28 | ```dar 29 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 30 | ``` 31 | 32 | ## 使用 33 | 34 | 通过创建 `WeatherBg` 配置天气类型,需要传入宽高来完成最终展示 35 | 36 | ```dart 37 | WeatherBg(weatherType: _weatherType,width: _width,height: _height,) 38 | ``` 39 | 40 | ## 截图效果 41 | 42 | 全屏沉浸式翻页效果 43 | 44 | ![home](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/92cbc9dbbd19419793ffec0e9f04457b~tplv-k3u1fbpfcp-zoom-1.image) 45 | 46 | 47 | 城市管理列表效果 48 | 49 | ![list](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e6076f6ca3af4d3a8778313006ab9663~tplv-k3u1fbpfcp-zoom-1.image) 50 | 51 | 52 | 多样的宫格效果 53 | 54 | ![grid](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/d2e396e151764a7e8f86e798282833b9~tplv-k3u1fbpfcp-zoom-1.image) 55 | 56 | 57 | 切换天气类型时的过度动画效果 58 | 59 | ![check](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5c4e75165cbb4a87b8176baa636c432d~tplv-k3u1fbpfcp-zoom-1.image) 60 | 61 | 62 | 修改宽高的适配效果 63 | 64 | ![width_height](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c8a4002423db4b77b0d2374f6da1c055~tplv-k3u1fbpfcp-zoom-1.image) 65 | 66 | ## License 67 | 68 | MIT -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Exceptions to above rules. 44 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 45 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: bbfbf1770cca2da7c82e887e4e4af910034800b6 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_weather_bg_example 2 | 3 | Demonstrates how to use the flutter_weather_bg plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "com.example.flutter_weather_bg_example" 37 | minSdkVersion 21 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | } 42 | 43 | buildTypes { 44 | release { 45 | // TODO: Add your own signing config for the release build. 46 | // Signing with the debug keys for now, so `flutter run --release` works. 47 | signingConfig signingConfigs.debug 48 | } 49 | } 50 | } 51 | 52 | flutter { 53 | source '../..' 54 | } 55 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 23 | 27 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/flutter_weather_bg_example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.flutter_weather_bg_example; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.5.3' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 32 | end 33 | 34 | post_install do |installer| 35 | installer.pods_project.targets.each do |target| 36 | flutter_additional_ios_build_settings(target) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 13 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 34 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 35 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 36 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 37 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 40 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 41 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 9740EEB11CF90186004384FC /* Flutter */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 64 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 65 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 66 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 67 | ); 68 | name = Flutter; 69 | sourceTree = ""; 70 | }; 71 | 97C146E51CF9000F007C117D = { 72 | isa = PBXGroup; 73 | children = ( 74 | 9740EEB11CF90186004384FC /* Flutter */, 75 | 97C146F01CF9000F007C117D /* Runner */, 76 | 97C146EF1CF9000F007C117D /* Products */, 77 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, 78 | ); 79 | sourceTree = ""; 80 | }; 81 | 97C146EF1CF9000F007C117D /* Products */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 97C146EE1CF9000F007C117D /* Runner.app */, 85 | ); 86 | name = Products; 87 | sourceTree = ""; 88 | }; 89 | 97C146F01CF9000F007C117D /* Runner */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 93 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 94 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 95 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 96 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 97 | 97C147021CF9000F007C117D /* Info.plist */, 98 | 97C146F11CF9000F007C117D /* Supporting Files */, 99 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 100 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 101 | ); 102 | path = Runner; 103 | sourceTree = ""; 104 | }; 105 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 97C146F21CF9000F007C117D /* main.m */, 109 | ); 110 | name = "Supporting Files"; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | 97C146ED1CF9000F007C117D /* Runner */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 119 | buildPhases = ( 120 | 9740EEB61CF901F6004384FC /* Run Script */, 121 | 97C146EA1CF9000F007C117D /* Sources */, 122 | 97C146EB1CF9000F007C117D /* Frameworks */, 123 | 97C146EC1CF9000F007C117D /* Resources */, 124 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 125 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 126 | ); 127 | buildRules = ( 128 | ); 129 | dependencies = ( 130 | ); 131 | name = Runner; 132 | productName = Runner; 133 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 134 | productType = "com.apple.product-type.application"; 135 | }; 136 | /* End PBXNativeTarget section */ 137 | 138 | /* Begin PBXProject section */ 139 | 97C146E61CF9000F007C117D /* Project object */ = { 140 | isa = PBXProject; 141 | attributes = { 142 | LastUpgradeCheck = 1020; 143 | ORGANIZATIONNAME = ""; 144 | TargetAttributes = { 145 | 97C146ED1CF9000F007C117D = { 146 | CreatedOnToolsVersion = 7.3.1; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 151 | compatibilityVersion = "Xcode 9.3"; 152 | developmentRegion = en; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = 97C146E51CF9000F007C117D; 159 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 160 | projectDirPath = ""; 161 | projectRoot = ""; 162 | targets = ( 163 | 97C146ED1CF9000F007C117D /* Runner */, 164 | ); 165 | }; 166 | /* End PBXProject section */ 167 | 168 | /* Begin PBXResourcesBuildPhase section */ 169 | 97C146EC1CF9000F007C117D /* Resources */ = { 170 | isa = PBXResourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 174 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 175 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 176 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXResourcesBuildPhase section */ 181 | 182 | /* Begin PBXShellScriptBuildPhase section */ 183 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 184 | isa = PBXShellScriptBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | ); 188 | inputPaths = ( 189 | ); 190 | name = "Thin Binary"; 191 | outputPaths = ( 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | shellPath = /bin/sh; 195 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 196 | }; 197 | 9740EEB61CF901F6004384FC /* Run Script */ = { 198 | isa = PBXShellScriptBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | ); 202 | inputPaths = ( 203 | ); 204 | name = "Run Script"; 205 | outputPaths = ( 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | shellPath = /bin/sh; 209 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 210 | }; 211 | /* End PBXShellScriptBuildPhase section */ 212 | 213 | /* Begin PBXSourcesBuildPhase section */ 214 | 97C146EA1CF9000F007C117D /* Sources */ = { 215 | isa = PBXSourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 219 | 97C146F31CF9000F007C117D /* main.m in Sources */, 220 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | }; 224 | /* End PBXSourcesBuildPhase section */ 225 | 226 | /* Begin PBXVariantGroup section */ 227 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 228 | isa = PBXVariantGroup; 229 | children = ( 230 | 97C146FB1CF9000F007C117D /* Base */, 231 | ); 232 | name = Main.storyboard; 233 | sourceTree = ""; 234 | }; 235 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 236 | isa = PBXVariantGroup; 237 | children = ( 238 | 97C147001CF9000F007C117D /* Base */, 239 | ); 240 | name = LaunchScreen.storyboard; 241 | sourceTree = ""; 242 | }; 243 | /* End PBXVariantGroup section */ 244 | 245 | /* Begin XCBuildConfiguration section */ 246 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ALWAYS_SEARCH_USER_PATHS = NO; 250 | CLANG_ANALYZER_NONNULL = YES; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 256 | CLANG_WARN_BOOL_CONVERSION = YES; 257 | CLANG_WARN_COMMA = YES; 258 | CLANG_WARN_CONSTANT_CONVERSION = YES; 259 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 260 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 261 | CLANG_WARN_EMPTY_BODY = YES; 262 | CLANG_WARN_ENUM_CONVERSION = YES; 263 | CLANG_WARN_INFINITE_RECURSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 266 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 267 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 269 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 270 | CLANG_WARN_STRICT_PROTOTYPES = YES; 271 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 272 | CLANG_WARN_UNREACHABLE_CODE = YES; 273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 274 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 277 | ENABLE_NS_ASSERTIONS = NO; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_NO_COMMON_BLOCKS = YES; 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 288 | MTL_ENABLE_DEBUG_INFO = NO; 289 | SDKROOT = iphoneos; 290 | SUPPORTED_PLATFORMS = iphoneos; 291 | TARGETED_DEVICE_FAMILY = "1,2"; 292 | VALIDATE_PRODUCT = YES; 293 | }; 294 | name = Profile; 295 | }; 296 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 297 | isa = XCBuildConfiguration; 298 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 299 | buildSettings = { 300 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 301 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 302 | ENABLE_BITCODE = NO; 303 | FRAMEWORK_SEARCH_PATHS = ( 304 | "$(inherited)", 305 | "$(PROJECT_DIR)/Flutter", 306 | ); 307 | INFOPLIST_FILE = Runner/Info.plist; 308 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 309 | LIBRARY_SEARCH_PATHS = ( 310 | "$(inherited)", 311 | "$(PROJECT_DIR)/Flutter", 312 | ); 313 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeatherBgExample; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | VERSIONING_SYSTEM = "apple-generic"; 316 | }; 317 | name = Profile; 318 | }; 319 | 97C147031CF9000F007C117D /* Debug */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_ANALYZER_NONNULL = YES; 324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 325 | CLANG_CXX_LIBRARY = "libc++"; 326 | CLANG_ENABLE_MODULES = YES; 327 | CLANG_ENABLE_OBJC_ARC = YES; 328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_COMMA = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INFINITE_RECURSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 339 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 340 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 343 | CLANG_WARN_STRICT_PROTOTYPES = YES; 344 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = dwarf; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | ENABLE_TESTABILITY = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_DYNAMIC_NO_PIC = NO; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 367 | MTL_ENABLE_DEBUG_INFO = YES; 368 | ONLY_ACTIVE_ARCH = YES; 369 | SDKROOT = iphoneos; 370 | TARGETED_DEVICE_FAMILY = "1,2"; 371 | }; 372 | name = Debug; 373 | }; 374 | 97C147041CF9000F007C117D /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ALWAYS_SEARCH_USER_PATHS = NO; 378 | CLANG_ANALYZER_NONNULL = YES; 379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_ENABLE_MODULES = YES; 382 | CLANG_ENABLE_OBJC_ARC = YES; 383 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 384 | CLANG_WARN_BOOL_CONVERSION = YES; 385 | CLANG_WARN_COMMA = YES; 386 | CLANG_WARN_CONSTANT_CONVERSION = YES; 387 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 388 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 389 | CLANG_WARN_EMPTY_BODY = YES; 390 | CLANG_WARN_ENUM_CONVERSION = YES; 391 | CLANG_WARN_INFINITE_RECURSION = YES; 392 | CLANG_WARN_INT_CONVERSION = YES; 393 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 395 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 397 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 398 | CLANG_WARN_STRICT_PROTOTYPES = YES; 399 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 400 | CLANG_WARN_UNREACHABLE_CODE = YES; 401 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 402 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 403 | COPY_PHASE_STRIP = NO; 404 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 405 | ENABLE_NS_ASSERTIONS = NO; 406 | ENABLE_STRICT_OBJC_MSGSEND = YES; 407 | GCC_C_LANGUAGE_STANDARD = gnu99; 408 | GCC_NO_COMMON_BLOCKS = YES; 409 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 410 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 411 | GCC_WARN_UNDECLARED_SELECTOR = YES; 412 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 413 | GCC_WARN_UNUSED_FUNCTION = YES; 414 | GCC_WARN_UNUSED_VARIABLE = YES; 415 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 416 | MTL_ENABLE_DEBUG_INFO = NO; 417 | SDKROOT = iphoneos; 418 | SUPPORTED_PLATFORMS = iphoneos; 419 | TARGETED_DEVICE_FAMILY = "1,2"; 420 | VALIDATE_PRODUCT = YES; 421 | }; 422 | name = Release; 423 | }; 424 | 97C147061CF9000F007C117D /* Debug */ = { 425 | isa = XCBuildConfiguration; 426 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 427 | buildSettings = { 428 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 429 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 430 | ENABLE_BITCODE = NO; 431 | FRAMEWORK_SEARCH_PATHS = ( 432 | "$(inherited)", 433 | "$(PROJECT_DIR)/Flutter", 434 | ); 435 | INFOPLIST_FILE = Runner/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 437 | LIBRARY_SEARCH_PATHS = ( 438 | "$(inherited)", 439 | "$(PROJECT_DIR)/Flutter", 440 | ); 441 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeatherBgExample; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | VERSIONING_SYSTEM = "apple-generic"; 444 | }; 445 | name = Debug; 446 | }; 447 | 97C147071CF9000F007C117D /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 453 | ENABLE_BITCODE = NO; 454 | FRAMEWORK_SEARCH_PATHS = ( 455 | "$(inherited)", 456 | "$(PROJECT_DIR)/Flutter", 457 | ); 458 | INFOPLIST_FILE = Runner/Info.plist; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 460 | LIBRARY_SEARCH_PATHS = ( 461 | "$(inherited)", 462 | "$(PROJECT_DIR)/Flutter", 463 | ); 464 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeatherBgExample; 465 | PRODUCT_NAME = "$(TARGET_NAME)"; 466 | VERSIONING_SYSTEM = "apple-generic"; 467 | }; 468 | name = Release; 469 | }; 470 | /* End XCBuildConfiguration section */ 471 | 472 | /* Begin XCConfigurationList section */ 473 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 474 | isa = XCConfigurationList; 475 | buildConfigurations = ( 476 | 97C147031CF9000F007C117D /* Debug */, 477 | 97C147041CF9000F007C117D /* Release */, 478 | 249021D3217E4FDB00AE95B9 /* Profile */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 97C147061CF9000F007C117D /* Debug */, 487 | 97C147071CF9000F007C117D /* Release */, 488 | 249021D4217E4FDB00AE95B9 /* Profile */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | defaultConfigurationName = Release; 492 | }; 493 | /* End XCConfigurationList section */ 494 | }; 495 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 496 | } 497 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_weather_bg_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/anim_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 3 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 4 | 5 | /// 主要提供两个实例 6 | /// 1. 切换天气类型时,会有过度动画 7 | /// 2. 动态改变宽高,绘制的相关逻辑同步发生改变 8 | class AnimViewWidget extends StatefulWidget { 9 | @override 10 | _AnimViewWidgetState createState() => _AnimViewWidgetState(); 11 | } 12 | 13 | class _AnimViewWidgetState extends State { 14 | WeatherType _weatherType = WeatherType.sunny; 15 | double _width = 100; 16 | double _height = 200; 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | var radius = 5 + (_width - 100) / 200 * 10; 21 | 22 | return Scaffold( 23 | appBar: AppBar( 24 | title: Text("AnimView"), 25 | actions: [ 26 | PopupMenuButton( 27 | itemBuilder: (context) { 28 | return >[ 29 | ...WeatherType.values 30 | .map((e) => PopupMenuItem( 31 | value: e, 32 | child: Text("${WeatherUtil.getWeatherDesc(e)}"), 33 | )) 34 | .toList(), 35 | ]; 36 | }, 37 | initialValue: _weatherType, 38 | child: Row( 39 | mainAxisAlignment: MainAxisAlignment.center, 40 | children: [ 41 | Text("${WeatherUtil.getWeatherDesc(_weatherType)}"), 42 | Icon(Icons.more_vert) 43 | ], 44 | ), 45 | onSelected: (count) { 46 | setState(() { 47 | _weatherType = count; 48 | }); 49 | }, 50 | ), 51 | ], 52 | ), 53 | body: Container( 54 | child: Column( 55 | mainAxisSize: MainAxisSize.min, 56 | children: [ 57 | Card( 58 | elevation: 7, 59 | margin: EdgeInsets.only(top: 15), 60 | shape: RoundedRectangleBorder( 61 | borderRadius: BorderRadius.circular(radius)), 62 | child: ClipPath( 63 | clipper: ShapeBorderClipper( 64 | shape: RoundedRectangleBorder( 65 | borderRadius: BorderRadius.circular(radius))), 66 | child: Container( 67 | child: WeatherBg( 68 | weatherType: _weatherType, 69 | width: _width, 70 | height: _height, 71 | ), 72 | ), 73 | ), 74 | ), 75 | SizedBox( 76 | height: 20, 77 | ), 78 | 79 | SizedBox( 80 | height: 20, 81 | ), 82 | Slider( 83 | min: 100, 84 | max: 300, 85 | label: "$_width", 86 | divisions: 200, 87 | onChanged: (value) { 88 | setState(() { 89 | _width = value; 90 | }); 91 | }, 92 | value: _width, 93 | ), 94 | SizedBox( 95 | height: 20, 96 | ), 97 | Slider( 98 | min: 200, 99 | max: 600, 100 | label: "$_height", 101 | divisions: 400, 102 | onChanged: (value) { 103 | setState(() { 104 | _height = value; 105 | }); 106 | }, 107 | value: _height, 108 | ) 109 | ], 110 | ), 111 | ), 112 | ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /example/lib/grid_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/bg/weather_color_bg.dart'; 3 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 4 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 5 | 6 | /// 已宫格的形式展示多样的天气效果 7 | /// 同时,支持切换列数 8 | class GridViewWidget extends StatefulWidget { 9 | @override 10 | _GridViewWidgetState createState() => _GridViewWidgetState(); 11 | } 12 | 13 | class _GridViewWidgetState extends State { 14 | int _count = 2; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | title: Text("GridView"), 21 | actions: [ 22 | PopupMenuButton( 23 | itemBuilder: (context) { 24 | return >[ 25 | ...[1, 2, 3, 4, 5,] 26 | .map((e) => PopupMenuItem( 27 | value: e, 28 | child: Text("$e"), 29 | )) 30 | .toList(), 31 | ]; 32 | }, 33 | onSelected: (count) { 34 | setState(() { 35 | _count = count; 36 | }); 37 | }, 38 | ) 39 | ], 40 | ), 41 | body: Container( 42 | child: GridView.count( 43 | physics: BouncingScrollPhysics(), 44 | scrollDirection: Axis.vertical, 45 | crossAxisCount: _count, 46 | childAspectRatio: 1 / 2, 47 | children: WeatherType.values 48 | .map((e) => GridItemWidget( 49 | weatherType: e, 50 | count: _count, 51 | )) 52 | .toList(), 53 | ), 54 | )); 55 | } 56 | } 57 | 58 | class GridItemWidget extends StatelessWidget { 59 | final WeatherType weatherType; 60 | final int count; 61 | 62 | GridItemWidget({Key key, this.weatherType, this.count}) : super(key: key); 63 | 64 | @override 65 | Widget build(BuildContext context) { 66 | weatherPrint("grid item size: ${MediaQuery.of(context).size}"); 67 | var radius = 20.0 - 2 * count; 68 | var margin = 10.0 - count; 69 | return Card( 70 | elevation: 6, 71 | margin: EdgeInsets.all(margin), 72 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius)), 73 | child: ClipPath( 74 | clipper: ShapeBorderClipper(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius))), 75 | child: Stack( 76 | children: [ 77 | WeatherBg( 78 | weatherType: weatherType, 79 | width: MediaQuery.of(context).size.width / count, 80 | height: MediaQuery.of(context).size.width * 2, 81 | ), 82 | Center( 83 | child: Text( 84 | WeatherUtil.getWeatherDesc(weatherType), 85 | style: TextStyle( 86 | color: Colors.white, fontSize: 30 / count, fontWeight: FontWeight.bold), 87 | ), 88 | ) 89 | ], 90 | ), 91 | ), 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /example/lib/list_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 3 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 4 | 5 | class ListViewWidget extends StatefulWidget { 6 | @override 7 | _ListViewWidgetState createState() => _ListViewWidgetState(); 8 | } 9 | 10 | class _ListViewWidgetState extends State { 11 | @override 12 | Widget build(BuildContext context) { 13 | return Scaffold( 14 | appBar: AppBar( 15 | title: Text("listView"), 16 | ), 17 | body: ListView.separated( 18 | physics: BouncingScrollPhysics(), 19 | itemBuilder: (BuildContext context, int index) { 20 | return ListItemWidget( 21 | weatherType: WeatherType.values[index], 22 | ); 23 | }, 24 | separatorBuilder: (BuildContext context, int index) { 25 | return SizedBox( 26 | height: 5, 27 | ); 28 | }, 29 | itemCount: WeatherType.values.length, 30 | ), 31 | ); 32 | } 33 | } 34 | 35 | class ListItemWidget extends StatelessWidget { 36 | final WeatherType weatherType; 37 | 38 | ListItemWidget({Key key, this.weatherType}) : super(key: key); 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return Card( 43 | elevation: 4, 44 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), 45 | margin: EdgeInsets.symmetric(horizontal: 10, vertical: 8), 46 | child: ClipPath( 47 | child: Stack( 48 | children: [ 49 | WeatherBg( 50 | weatherType: weatherType, 51 | width: MediaQuery.of(context).size.width, 52 | height: 100, 53 | ), 54 | Container( 55 | alignment: Alignment(-0.8, 0), 56 | height: 100, 57 | child: Text( 58 | "北京", 59 | style: TextStyle( 60 | color: Colors.white, 61 | fontSize: 25, 62 | fontWeight: FontWeight.bold), 63 | ), 64 | ), 65 | Container( 66 | alignment: Alignment(0.8, 0), 67 | height: 100, 68 | child: Text( 69 | WeatherUtil.getWeatherDesc(weatherType), 70 | style: TextStyle( 71 | color: Colors.white, 72 | fontSize: 25, 73 | fontWeight: FontWeight.bold), 74 | ), 75 | ) 76 | ], 77 | ), 78 | clipper: ShapeBorderClipper( 79 | shape: RoundedRectangleBorder( 80 | borderRadius: BorderRadius.all(Radius.circular(20)))), 81 | ), 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 5 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 6 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 7 | import 'package:flutter_weather_bg_example/anim_view.dart'; 8 | 9 | import 'package:flutter_weather_bg_example/grid_view.dart'; 10 | import 'package:flutter_weather_bg_example/list_view.dart'; 11 | import 'package:flutter_weather_bg_example/page_view.dart'; 12 | 13 | void main() { 14 | runApp(MyApp()); 15 | } 16 | 17 | const routePage = "page"; 18 | const routeList = "list"; 19 | const routeGrid = "grid"; 20 | const routeAnim = "anim"; 21 | 22 | class MyApp extends StatefulWidget { 23 | @override 24 | _MyAppState createState() => _MyAppState(); 25 | } 26 | 27 | class _MyAppState extends State { 28 | @override 29 | void initState() { 30 | super.initState(); 31 | } 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return MaterialApp( 36 | routes: { 37 | routePage: (BuildContext context) { 38 | // 普通的侧滑样式 39 | return PageViewWidget(); 40 | }, 41 | routeList: (BuildContext context) { 42 | // 宫格样式 43 | return ListViewWidget(); 44 | }, 45 | routeGrid: (BuildContext context) { 46 | // 宫格样式 47 | return GridViewWidget(); 48 | }, 49 | routeAnim: (BuildContext context) { 50 | // 动态切换 宽高样式 51 | return AnimViewWidget(); 52 | } 53 | }, 54 | home: HomePage(), 55 | ); 56 | } 57 | } 58 | 59 | /// demo 首页布局 60 | class HomePage extends StatelessWidget { 61 | /// 创建首页 item 布局 62 | Widget _buildItem(BuildContext context, String routeName, String desc, 63 | WeatherType weatherType) { 64 | double width = MediaQuery.of(context).size.width; 65 | double marginLeft = 10.0; 66 | double marginTop = 8.0; 67 | double itemWidth = (width - marginLeft * 4) / 2; 68 | double itemHeight = itemWidth * 1.5; 69 | var radius = 10.0; 70 | return Container( 71 | width: itemWidth, 72 | height: itemHeight, 73 | child: Card( 74 | elevation: 7, 75 | margin: 76 | EdgeInsets.symmetric(horizontal: marginLeft, vertical: marginTop), 77 | shape: 78 | RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius)), 79 | child: ClipPath( 80 | clipper: ShapeBorderClipper( 81 | shape: RoundedRectangleBorder( 82 | borderRadius: BorderRadius.circular(radius))), 83 | child: Stack( 84 | children: [ 85 | WeatherBg( 86 | weatherType: weatherType, 87 | width: itemWidth, 88 | height: itemHeight, 89 | ), 90 | BackdropFilter( 91 | filter: ImageFilter.blur(sigmaX: 2.5, sigmaY: 2.5), 92 | child: InkWell( 93 | child: Center( 94 | child: Text( 95 | desc, 96 | style: TextStyle( 97 | color: Colors.white, 98 | fontWeight: FontWeight.bold, 99 | fontSize: 20), 100 | ), 101 | ), 102 | onTap: () { 103 | weatherPrint("name: $routeName"); 104 | Navigator.of(context).pushNamed(routeName); 105 | }, 106 | ), 107 | ), 108 | ], 109 | ), 110 | ), 111 | ), 112 | ); 113 | } 114 | 115 | @override 116 | Widget build(BuildContext context) { 117 | return Scaffold( 118 | body: Center( 119 | child: Wrap( 120 | children: [ 121 | _buildItem(context, routePage, "翻页效果", WeatherType.thunder), 122 | _buildItem(context, routeGrid, "宫格效果", WeatherType.sunnyNight), 123 | _buildItem(context, routeList, "列表效果", WeatherType.lightSnow), 124 | _buildItem(context, routeAnim, "切换效果", WeatherType.sunny), 125 | ], 126 | ), 127 | ), 128 | ); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /example/lib/page_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 3 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 4 | 5 | /// 普通的 ViewPager 展示样式 6 | class PageViewWidget extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return Scaffold( 10 | body: Container( 11 | child: PageView.builder( 12 | physics: BouncingScrollPhysics(), 13 | itemBuilder: (BuildContext context, int index) { 14 | weatherPrint("pageView: ${MediaQuery.of(context).size}"); 15 | return Stack( 16 | children: [ 17 | WeatherBg( 18 | weatherType: WeatherType.values[index], 19 | width: MediaQuery.of(context).size.width, 20 | height: MediaQuery.of(context).size.height, 21 | ), 22 | Center( 23 | child: Text( 24 | WeatherUtil.getWeatherDesc(WeatherType.values[index]), 25 | style: TextStyle( 26 | color: Colors.white, fontSize: 30, fontWeight: FontWeight.bold), 27 | ), 28 | ) 29 | ], 30 | ); 31 | }, 32 | itemCount: WeatherType.values.length, 33 | ), 34 | ), 35 | ); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.4.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.0.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.0.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.1.3" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.0.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "1.14.13" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "0.1.3" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.1.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | flutter_weather_bg: 71 | dependency: "direct main" 72 | description: 73 | path: ".." 74 | relative: true 75 | source: path 76 | version: "2.8.0" 77 | matcher: 78 | dependency: transitive 79 | description: 80 | name: matcher 81 | url: "https://pub.flutter-io.cn" 82 | source: hosted 83 | version: "0.12.8" 84 | meta: 85 | dependency: transitive 86 | description: 87 | name: meta 88 | url: "https://pub.flutter-io.cn" 89 | source: hosted 90 | version: "1.1.8" 91 | path: 92 | dependency: transitive 93 | description: 94 | name: path 95 | url: "https://pub.flutter-io.cn" 96 | source: hosted 97 | version: "1.7.0" 98 | sky_engine: 99 | dependency: transitive 100 | description: flutter 101 | source: sdk 102 | version: "0.0.99" 103 | source_span: 104 | dependency: transitive 105 | description: 106 | name: source_span 107 | url: "https://pub.flutter-io.cn" 108 | source: hosted 109 | version: "1.7.0" 110 | stack_trace: 111 | dependency: transitive 112 | description: 113 | name: stack_trace 114 | url: "https://pub.flutter-io.cn" 115 | source: hosted 116 | version: "1.9.5" 117 | stream_channel: 118 | dependency: transitive 119 | description: 120 | name: stream_channel 121 | url: "https://pub.flutter-io.cn" 122 | source: hosted 123 | version: "2.0.0" 124 | string_scanner: 125 | dependency: transitive 126 | description: 127 | name: string_scanner 128 | url: "https://pub.flutter-io.cn" 129 | source: hosted 130 | version: "1.0.5" 131 | term_glyph: 132 | dependency: transitive 133 | description: 134 | name: term_glyph 135 | url: "https://pub.flutter-io.cn" 136 | source: hosted 137 | version: "1.1.0" 138 | test_api: 139 | dependency: transitive 140 | description: 141 | name: test_api 142 | url: "https://pub.flutter-io.cn" 143 | source: hosted 144 | version: "0.2.17" 145 | typed_data: 146 | dependency: transitive 147 | description: 148 | name: typed_data 149 | url: "https://pub.flutter-io.cn" 150 | source: hosted 151 | version: "1.2.0" 152 | vector_math: 153 | dependency: transitive 154 | description: 155 | name: vector_math 156 | url: "https://pub.flutter-io.cn" 157 | source: hosted 158 | version: "2.0.8" 159 | sdks: 160 | dart: ">=2.9.0-14.0.dev <3.0.0" 161 | flutter: ">=1.20.0 <2.0.0" 162 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_weather_bg_example 2 | description: Demonstrates how to use the flutter_weather_bg plugin. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | environment: 9 | sdk: ">=2.7.0 <3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | flutter_weather_bg: 16 | # When depending on this package from a real application you should use: 17 | # flutter_weather_bg: ^x.y.z 18 | # See https://dart.dev/tools/pub/dependencies#version-constraints 19 | # The example app is bundled with the plugin so we use a path dependency on 20 | # the parent directory to use the current plugin's version. 21 | path: ../ 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | cupertino_icons: ^0.1.3 26 | 27 | dev_dependencies: 28 | flutter_test: 29 | sdk: flutter 30 | 31 | # For information on the generic Dart part of this file, see the 32 | # following page: https://dart.dev/tools/pub/pubspec 33 | 34 | # The following section is specific to Flutter. 35 | flutter: 36 | 37 | # The following line ensures that the Material Icons font is 38 | # included with your application, so that you can use the icons in 39 | # the material Icons class. 40 | uses-material-design: true 41 | 42 | # To add assets to your application, add an assets section, like this: 43 | # assets: 44 | # - images/a_dot_burr.jpeg 45 | # - images/a_dot_ham.jpeg 46 | 47 | # An image asset can refer to one or more resolution-specific "variants", see 48 | # https://flutter.dev/assets-and-images/#resolution-aware. 49 | 50 | # For details regarding adding assets from package dependencies, see 51 | # https://flutter.dev/assets-and-images/#from-packages 52 | 53 | # To add custom fonts to your application, add a fonts section here, 54 | # in this "flutter" section. Each entry in this list should have a 55 | # "family" key with the font family name, and a "fonts" key with a 56 | # list giving the asset and other descriptors for the font. For 57 | # example: 58 | # fonts: 59 | # - family: Schyler 60 | # fonts: 61 | # - asset: fonts/Schyler-Regular.ttf 62 | # - asset: fonts/Schyler-Italic.ttf 63 | # style: italic 64 | # - family: Trajan Pro 65 | # fonts: 66 | # - asset: fonts/TrajanPro.ttf 67 | # - asset: fonts/TrajanPro_Bold.ttf 68 | # weight: 700 69 | # 70 | # For details regarding fonts from package dependencies, 71 | # see https://flutter.dev/custom-fonts/#from-packages 72 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_weather_bg_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Platform version', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => widget is Text && 22 | widget.data.startsWith('Running on:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /flutter_weather_bg.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /images/cloud.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/cloud.webp -------------------------------------------------------------------------------- /images/lightning0.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/lightning0.webp -------------------------------------------------------------------------------- /images/lightning1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/lightning1.webp -------------------------------------------------------------------------------- /images/lightning2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/lightning2.webp -------------------------------------------------------------------------------- /images/lightning3.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/lightning3.webp -------------------------------------------------------------------------------- /images/lightning4.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/lightning4.webp -------------------------------------------------------------------------------- /images/rain.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/rain.webp -------------------------------------------------------------------------------- /images/snow.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/snow.webp -------------------------------------------------------------------------------- /images/sun.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaweizi/flutter_weather_bg/a51545b225586910817610fd3bb4aa8b261df4bd/images/sun.webp -------------------------------------------------------------------------------- /lib/bg/weather_bg.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/bg/weather_cloud_bg.dart'; 3 | import 'package:flutter_weather_bg/bg/weather_color_bg.dart'; 4 | import 'package:flutter_weather_bg/bg/weather_night_star_bg.dart'; 5 | import 'package:flutter_weather_bg/bg/weather_rain_snow_bg.dart'; 6 | import 'package:flutter_weather_bg/bg/weather_thunder_bg.dart'; 7 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 8 | 9 | /// 最核心的类,集合背景&雷&雨雪&晴晚&流星效果 10 | /// 1. 支持动态切换大小 11 | /// 2. 支持渐变过度 12 | class WeatherBg extends StatefulWidget { 13 | final WeatherType weatherType; 14 | final double width; 15 | final double height; 16 | 17 | WeatherBg( 18 | {Key key, this.weatherType, @required this.width, @required this.height}) 19 | : super(key: key); 20 | 21 | @override 22 | _WeatherBgState createState() => _WeatherBgState(); 23 | } 24 | 25 | class _WeatherBgState extends State 26 | with SingleTickerProviderStateMixin { 27 | WeatherType _oldWeatherType; 28 | bool needChange = false; 29 | var state = CrossFadeState.showSecond; 30 | 31 | @override 32 | void didUpdateWidget(WeatherBg oldWidget) { 33 | super.didUpdateWidget(oldWidget); 34 | if (widget.weatherType != oldWidget.weatherType) { 35 | // 如果类别发生改变,需要 start 渐变动画 36 | _oldWeatherType = oldWidget.weatherType; 37 | needChange = true; 38 | } 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | var oldBgWidget; 44 | if (_oldWeatherType != null) { 45 | oldBgWidget = WeatherItemBg( 46 | weatherType: _oldWeatherType, 47 | width: widget.width, 48 | height: widget.height, 49 | ); 50 | } 51 | var currentBgWidget = WeatherItemBg( 52 | weatherType: widget.weatherType, 53 | width: widget.width, 54 | height: widget.height, 55 | ); 56 | if (oldBgWidget == null) { 57 | oldBgWidget = currentBgWidget; 58 | } 59 | var firstWidget = currentBgWidget; 60 | var secondWidget = currentBgWidget; 61 | if (needChange) { 62 | if (state == CrossFadeState.showSecond) { 63 | state = CrossFadeState.showFirst; 64 | firstWidget = currentBgWidget; 65 | secondWidget = oldBgWidget; 66 | } else { 67 | state = CrossFadeState.showSecond; 68 | secondWidget = currentBgWidget; 69 | firstWidget = oldBgWidget; 70 | } 71 | } 72 | needChange = false; 73 | return SizeInherited( 74 | child: AnimatedCrossFade( 75 | firstChild: firstWidget, 76 | secondChild: secondWidget, 77 | duration: Duration(milliseconds: 300), 78 | crossFadeState: state, 79 | ), 80 | size: Size(widget.width, widget.height), 81 | ); 82 | } 83 | } 84 | 85 | class WeatherItemBg extends StatelessWidget { 86 | final WeatherType weatherType; 87 | final width; 88 | final height; 89 | 90 | WeatherItemBg({Key key, this.weatherType, this.width, this.height}) 91 | : super(key: key); 92 | 93 | /// 构建晴晚背景效果 94 | Widget _buildNightStarBg() { 95 | if (weatherType == WeatherType.sunnyNight) { 96 | return WeatherNightStarBg( 97 | weatherType: weatherType, 98 | ); 99 | } 100 | return Container(); 101 | } 102 | 103 | /// 构建雷暴效果 104 | Widget _buildThunderBg() { 105 | if (weatherType == WeatherType.thunder) { 106 | return WeatherThunderBg( 107 | weatherType: weatherType, 108 | ); 109 | } 110 | return Container(); 111 | } 112 | 113 | /// 构建雨雪背景效果 114 | Widget _buildRainSnowBg() { 115 | if (WeatherUtil.isSnowRain(weatherType)) { 116 | return WeatherRainSnowBg( 117 | weatherType: weatherType, 118 | viewWidth: width, 119 | viewHeight: height, 120 | ); 121 | } 122 | return Container(); 123 | } 124 | 125 | @override 126 | Widget build(BuildContext context) { 127 | return Container( 128 | width: width, 129 | height: height, 130 | child: ClipRect( 131 | child: Stack( 132 | children: [ 133 | WeatherColorBg(weatherType: weatherType), 134 | WeatherCloudBg( 135 | weatherType: weatherType, 136 | ), 137 | _buildRainSnowBg(), 138 | _buildThunderBg(), 139 | _buildNightStarBg(), 140 | ], 141 | ), 142 | ), 143 | ); 144 | } 145 | } 146 | 147 | class SizeInherited extends InheritedWidget { 148 | final Size size; 149 | 150 | const SizeInherited({ 151 | Key key, 152 | @required Widget child, 153 | @required this.size, 154 | }) : assert(child != null), 155 | super(key: key, child: child); 156 | 157 | static SizeInherited of(BuildContext context) { 158 | return context.dependOnInheritedWidgetOfExactType(); 159 | } 160 | 161 | @override 162 | bool updateShouldNotify(SizeInherited old) { 163 | return old.size != size; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /lib/bg/weather_cloud_bg.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 3 | import 'dart:ui' as ui; 4 | 5 | import 'package:flutter_weather_bg/utils/image_utils.dart'; 6 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 7 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 8 | 9 | //// 专门负责绘制背景云层 10 | //// 会根据不同的天气类型,选择需要绘制的图片类型,并控制缩放、渐变、位移以及染色,最终显示在屏幕上 11 | class WeatherCloudBg extends StatefulWidget { 12 | final WeatherType weatherType; 13 | 14 | WeatherCloudBg({Key key, this.weatherType}) : super(key: key); 15 | 16 | @override 17 | _WeatherCloudBgState createState() => _WeatherCloudBgState(); 18 | } 19 | 20 | class _WeatherCloudBgState extends State { 21 | List _images = []; 22 | 23 | Future fetchImages() async { 24 | weatherPrint("开始获取云层图片"); 25 | var image1 = await ImageUtils.getImage('images/cloud.webp'); 26 | var image2 = await ImageUtils.getImage('images/sun.webp'); 27 | _images.add(image1); 28 | _images.add(image2); 29 | weatherPrint("获取云层图片成功: ${_images?.length}"); 30 | setState(() {}); 31 | } 32 | 33 | @override 34 | void initState() { 35 | fetchImages(); 36 | super.initState(); 37 | } 38 | 39 | Widget _buildWidget() { 40 | if (_images != null && _images.isNotEmpty) { 41 | return CustomPaint( 42 | painter: BgPainter( 43 | _images, 44 | widget.weatherType, 45 | SizeInherited.of(context).size.width / 392.0, 46 | SizeInherited.of(context).size.width), 47 | ); 48 | } else { 49 | return Container(); 50 | } 51 | } 52 | 53 | @override 54 | Widget build(BuildContext context) { 55 | return _buildWidget(); 56 | } 57 | } 58 | 59 | class BgPainter extends CustomPainter { 60 | final _paint = Paint(); 61 | final List images; 62 | final WeatherType weatherType; 63 | final widthRatio; 64 | final width; 65 | 66 | BgPainter(this.images, this.weatherType, this.widthRatio, this.width); 67 | 68 | @override 69 | void paint(Canvas canvas, Size size) { 70 | if (images != null && images.isNotEmpty) { 71 | switch (weatherType) { 72 | case WeatherType.sunny: 73 | drawSunny(canvas, size); 74 | break; 75 | case WeatherType.cloudy: 76 | drawCloudy(canvas, size); 77 | break; 78 | case WeatherType.cloudyNight: 79 | drawCloudyNight(canvas, size); 80 | break; 81 | case WeatherType.overcast: 82 | drawOvercast(canvas, size); 83 | break; 84 | case WeatherType.lightRainy: 85 | drawLightRainy(canvas, size); 86 | break; 87 | case WeatherType.middleRainy: 88 | drawMiddleRainy(canvas, size); 89 | break; 90 | case WeatherType.heavyRainy: 91 | case WeatherType.thunder: 92 | drawHeavyRainy(canvas, size); 93 | break; 94 | case WeatherType.hazy: 95 | drawHazy(canvas, size); 96 | break; 97 | case WeatherType.foggy: 98 | drawFoggy(canvas, size); 99 | break; 100 | case WeatherType.lightSnow: 101 | drawLightSnow(canvas, size); 102 | break; 103 | case WeatherType.middleSnow: 104 | drawMiddleSnow(canvas, size); 105 | break; 106 | case WeatherType.heavySnow: 107 | drawHeavySnow(canvas, size); 108 | break; 109 | case WeatherType.dusty: 110 | drawDusty(canvas, size); 111 | break; 112 | default: 113 | break; 114 | } 115 | } 116 | } 117 | 118 | /// 绘制阳光 119 | void drawSunny(Canvas canvas, Size size) { 120 | ui.Image image = images[0]; 121 | ui.Image image1 = images[1]; 122 | _paint.maskFilter = MaskFilter.blur(BlurStyle.normal, 40); 123 | canvas.save(); 124 | final sunScale = 1.2 * widthRatio; 125 | canvas.scale(sunScale, sunScale); 126 | var offset = Offset(width.toDouble() - image1.width.toDouble() * sunScale, 127 | -image1.width.toDouble() / 2); 128 | canvas.drawImage(image1, offset, _paint); 129 | canvas.restore(); 130 | 131 | canvas.save(); 132 | final scale = 0.6 * widthRatio; 133 | ui.Offset offset1 = ui.Offset(-100, -100); 134 | canvas.scale(scale); 135 | canvas.drawImage(image, offset1, _paint); 136 | canvas.restore(); 137 | } 138 | 139 | void drawCloudy(Canvas canvas, Size size) { 140 | ui.Image image = images[0]; 141 | canvas.save(); 142 | const identity = ColorFilter.matrix([ 143 | 1, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 1, 150 | 0, 151 | 0, 152 | 0, 153 | 0, 154 | 0, 155 | 1, 156 | 0, 157 | 0, 158 | 0, 159 | 0, 160 | 0, 161 | 0.9, 162 | 0, 163 | ]); 164 | _paint.colorFilter = identity; 165 | final scale = 0.8 * widthRatio; 166 | ui.Offset offset1 = ui.Offset(0, -200); 167 | ui.Offset offset2 = ui.Offset(-image.width / 2, -130); 168 | ui.Offset offset3 = ui.Offset(100, 0); 169 | canvas.scale(scale); 170 | canvas.drawImage(image, offset1, _paint); 171 | canvas.drawImage(image, offset2, _paint); 172 | canvas.drawImage(image, offset3, _paint); 173 | canvas.restore(); 174 | } 175 | 176 | /// 绘制多云的夜晚效果 177 | void drawCloudyNight(Canvas canvas, Size size) { 178 | ui.Image image = images[0]; 179 | canvas.save(); 180 | const identity = ColorFilter.matrix([ 181 | 0.32, 182 | 0, 183 | 0, 184 | 0, 185 | 0, 186 | 0, 187 | 0.39, 188 | 0, 189 | 0, 190 | 0, 191 | 0, 192 | 0, 193 | 0.52, 194 | 0, 195 | 0, 196 | 0, 197 | 0, 198 | 0, 199 | 0.9, 200 | 0, 201 | ]); 202 | _paint.colorFilter = identity; 203 | final scale = 0.8 * widthRatio; 204 | ui.Offset offset1 = ui.Offset(0, -200); 205 | ui.Offset offset2 = ui.Offset(-image.width / 2, -130); 206 | ui.Offset offset3 = ui.Offset(100, 0); 207 | canvas.scale(scale, scale); 208 | canvas.drawImage(image, offset1, _paint); 209 | canvas.drawImage(image, offset2, _paint); 210 | canvas.drawImage(image, offset3, _paint); 211 | canvas.restore(); 212 | } 213 | 214 | /// 绘制阴天 215 | void drawOvercast(Canvas canvas, Size size) { 216 | ui.Image image = images[0]; 217 | canvas.save(); 218 | const identity = ColorFilter.matrix([ 219 | 1, 220 | 0, 221 | 0, 222 | 0, 223 | 0, 224 | 0, 225 | 1, 226 | 0, 227 | 0, 228 | 0, 229 | 0, 230 | 0, 231 | 1, 232 | 0, 233 | 0, 234 | 0, 235 | 0, 236 | 0, 237 | 0.7, 238 | 0, 239 | ]); 240 | _paint.colorFilter = identity; 241 | final scale = 0.8 * widthRatio; 242 | ui.Offset offset1 = ui.Offset(0, -200); 243 | ui.Offset offset2 = ui.Offset(-image.width / 2, -130); 244 | ui.Offset offset3 = ui.Offset(100, 0); 245 | canvas.scale(scale, scale); 246 | canvas.drawImage(image, offset1, _paint); 247 | canvas.drawImage(image, offset2, _paint); 248 | canvas.drawImage(image, offset3, _paint); 249 | canvas.restore(); 250 | } 251 | 252 | /// 绘制小雨效果 253 | void drawLightRainy(Canvas canvas, Size size) { 254 | ui.Image image = images[0]; 255 | canvas.save(); 256 | const identity = ColorFilter.matrix([ 257 | 0.45, 258 | 0, 259 | 0, 260 | 0, 261 | 0, 262 | 0, 263 | 0.52, 264 | 0, 265 | 0, 266 | 0, 267 | 0, 268 | 0, 269 | 0.6, 270 | 0, 271 | 0, 272 | 0, 273 | 0, 274 | 0, 275 | 1, 276 | 0, 277 | ]); 278 | _paint.colorFilter = identity; 279 | final scale = 0.8 * widthRatio; 280 | ui.Offset offset1 = ui.Offset(-380, -150); 281 | ui.Offset offset2 = ui.Offset(0, -60); 282 | ui.Offset offset3 = ui.Offset(0, 60); 283 | canvas.scale(scale); 284 | canvas.drawImage(image, offset1, _paint); 285 | canvas.drawImage(image, offset2, _paint); 286 | canvas.drawImage(image, offset3, _paint); 287 | canvas.restore(); 288 | } 289 | 290 | /// 绘制霾逻辑 291 | void drawHazy(Canvas canvas, Size size) { 292 | ui.Image image = images[0]; 293 | canvas.save(); 294 | const identity = ColorFilter.matrix([ 295 | 0.67, 296 | 0, 297 | 0, 298 | 0, 299 | 0, 300 | 0, 301 | 0.67, 302 | 0, 303 | 0, 304 | 0, 305 | 0, 306 | 0, 307 | 0.67, 308 | 0, 309 | 0, 310 | 0, 311 | 0, 312 | 0, 313 | 1, 314 | 0, 315 | ]); 316 | _paint.colorFilter = identity; 317 | final scale = 2.0 * widthRatio; 318 | ui.Offset offset1 = ui.Offset(-image.width.toDouble() * 0.5, -200); 319 | canvas.scale(scale, scale); 320 | canvas.drawImage(image, offset1, _paint); 321 | canvas.restore(); 322 | } 323 | 324 | /// 绘制雾 325 | void drawFoggy(Canvas canvas, Size size) { 326 | ui.Image image = images[0]; 327 | canvas.save(); 328 | const identity = ColorFilter.matrix([ 329 | 0.75, 330 | 0, 331 | 0, 332 | 0, 333 | 0, 334 | 0, 335 | 0.77, 336 | 0, 337 | 0, 338 | 0, 339 | 0, 340 | 0, 341 | 0.82, 342 | 0, 343 | 0, 344 | 0, 345 | 0, 346 | 0, 347 | 1, 348 | 0, 349 | ]); 350 | _paint.colorFilter = identity; 351 | final scale = 2.0 * widthRatio; 352 | ui.Offset offset1 = ui.Offset(-image.width.toDouble() * 0.5, -200); 353 | canvas.scale(scale, scale); 354 | canvas.drawImage(image, offset1, _paint); 355 | canvas.restore(); 356 | } 357 | 358 | /// 绘制浮尘 359 | void drawDusty(Canvas canvas, Size size) { 360 | ui.Image image = images[0]; 361 | canvas.save(); 362 | const identity = ColorFilter.matrix([ 363 | 0.62, 364 | 0, 365 | 0, 366 | 0, 367 | 0, 368 | 0, 369 | 0.55, 370 | 0, 371 | 0, 372 | 0, 373 | 0, 374 | 0, 375 | 0.45, 376 | 0, 377 | 0, 378 | 0, 379 | 0, 380 | 0, 381 | 1, 382 | 0, 383 | ]); 384 | _paint.colorFilter = identity; 385 | final scale = 2.0 * widthRatio; 386 | ui.Offset offset1 = ui.Offset(-image.width.toDouble() * 0.5, -200); 387 | canvas.scale(scale, scale); 388 | canvas.drawImage(image, offset1, _paint); 389 | canvas.restore(); 390 | } 391 | 392 | /// 绘制大雨 393 | void drawHeavyRainy(Canvas canvas, Size size) { 394 | ui.Image image = images[0]; 395 | canvas.save(); 396 | const identity = ColorFilter.matrix([ 397 | 0.19, 398 | 0, 399 | 0, 400 | 0, 401 | 0, 402 | 0, 403 | 0.2, 404 | 0, 405 | 0, 406 | 0, 407 | 0, 408 | 0, 409 | 0.22, 410 | 0, 411 | 0, 412 | 0, 413 | 0, 414 | 0, 415 | 1, 416 | 0, 417 | ]); 418 | _paint.colorFilter = identity; 419 | final scale = 0.8 * widthRatio; 420 | ui.Offset offset1 = ui.Offset(-380, -150); 421 | ui.Offset offset2 = ui.Offset(0, -60); 422 | ui.Offset offset3 = ui.Offset(0, 60); 423 | canvas.scale(scale, scale); 424 | canvas.drawImage(image, offset1, _paint); 425 | canvas.drawImage(image, offset2, _paint); 426 | canvas.drawImage(image, offset3, _paint); 427 | canvas.restore(); 428 | } 429 | 430 | /// 绘制中雨 431 | void drawMiddleRainy(Canvas canvas, Size size) { 432 | ui.Image image = images[0]; 433 | canvas.save(); 434 | const identity = ColorFilter.matrix([ 435 | 0.16, 436 | 0, 437 | 0, 438 | 0, 439 | 0, 440 | 0, 441 | 0.22, 442 | 0, 443 | 0, 444 | 0, 445 | 0, 446 | 0, 447 | 0.31, 448 | 0, 449 | 0, 450 | 0, 451 | 0, 452 | 0, 453 | 1, 454 | 0, 455 | ]); 456 | _paint.colorFilter = identity; 457 | final scale = 0.8 * widthRatio; 458 | ui.Offset offset1 = ui.Offset(-380, -150); 459 | ui.Offset offset2 = ui.Offset(0, -60); 460 | ui.Offset offset3 = ui.Offset(0, 60); 461 | canvas.scale(scale, scale); 462 | canvas.drawImage(image, offset1, _paint); 463 | canvas.drawImage(image, offset2, _paint); 464 | canvas.drawImage(image, offset3, _paint); 465 | canvas.restore(); 466 | } 467 | 468 | /// 绘制小雪 469 | void drawLightSnow(Canvas canvas, Size size) { 470 | ui.Image image = images[0]; 471 | canvas.save(); 472 | const identity = ColorFilter.matrix([ 473 | 0.67, 474 | 0, 475 | 0, 476 | 0, 477 | 0, 478 | 0, 479 | 0.75, 480 | 0, 481 | 0, 482 | 0, 483 | 0, 484 | 0, 485 | 0.87, 486 | 0, 487 | 0, 488 | 0, 489 | 0, 490 | 0, 491 | 1, 492 | 0, 493 | ]); 494 | _paint.colorFilter = identity; 495 | final scale = 0.8 * widthRatio; 496 | ui.Offset offset1 = ui.Offset(-380, -100); 497 | ui.Offset offset2 = ui.Offset(0, -170); 498 | canvas.scale(scale, scale); 499 | canvas.drawImage(image, offset1, _paint); 500 | canvas.drawImage(image, offset2, _paint); 501 | canvas.restore(); 502 | } 503 | 504 | /// 绘制中雪 505 | void drawMiddleSnow(Canvas canvas, Size size) { 506 | ui.Image image = images[0]; 507 | canvas.save(); 508 | const identity = ColorFilter.matrix([ 509 | 0.7, 510 | 0, 511 | 0, 512 | 0, 513 | 0, 514 | 0, 515 | 0.77, 516 | 0, 517 | 0, 518 | 0, 519 | 0, 520 | 0, 521 | 0.87, 522 | 0, 523 | 0, 524 | 0, 525 | 0, 526 | 0, 527 | 1, 528 | 0, 529 | ]); 530 | _paint.colorFilter = identity; 531 | final scale = 0.8 * widthRatio; 532 | ui.Offset offset1 = ui.Offset(-380, -100); 533 | ui.Offset offset2 = ui.Offset(0, -170); 534 | canvas.scale(scale, scale); 535 | canvas.drawImage(image, offset1, _paint); 536 | canvas.drawImage(image, offset2, _paint); 537 | canvas.restore(); 538 | } 539 | 540 | /// 绘制大雪 541 | void drawHeavySnow(Canvas canvas, Size size) { 542 | ui.Image image = images[0]; 543 | canvas.save(); 544 | const identity = ColorFilter.matrix([ 545 | 0.74, 546 | 0, 547 | 0, 548 | 0, 549 | 0, 550 | 0, 551 | 0.74, 552 | 0, 553 | 0, 554 | 0, 555 | 0, 556 | 0, 557 | 0.81, 558 | 0, 559 | 0, 560 | 0, 561 | 0, 562 | 0, 563 | 1, 564 | 0, 565 | ]); 566 | _paint.colorFilter = identity; 567 | final scale = 0.8 * widthRatio; 568 | ui.Offset offset1 = ui.Offset(-380, -100); 569 | ui.Offset offset2 = ui.Offset(0, -170); 570 | canvas.scale(scale, scale); 571 | canvas.drawImage(image, offset1, _paint); 572 | canvas.drawImage(image, offset2, _paint); 573 | canvas.restore(); 574 | } 575 | 576 | @override 577 | bool shouldRepaint(CustomPainter oldDelegate) { 578 | return false; 579 | } 580 | } 581 | -------------------------------------------------------------------------------- /lib/bg/weather_color_bg.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 3 | 4 | /// 颜色背景层 5 | class WeatherColorBg extends StatelessWidget { 6 | final WeatherType weatherType; 7 | 8 | /// 控制背景的高度 9 | final double height; 10 | 11 | WeatherColorBg({Key key, this.weatherType, this.height}) : super(key: key); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Container( 16 | height: height, 17 | decoration: BoxDecoration( 18 | gradient: LinearGradient( 19 | colors: WeatherUtil.getColor(weatherType), 20 | stops: [0, 1], 21 | begin: Alignment.topCenter, 22 | end: Alignment.bottomCenter, 23 | )), 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/bg/weather_night_star_bg.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 5 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 6 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 7 | import 'dart:ui' as ui; 8 | 9 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 10 | 11 | //// 晴晚&流星层 12 | class WeatherNightStarBg extends StatefulWidget { 13 | final WeatherType weatherType; 14 | 15 | WeatherNightStarBg({Key key, this.weatherType}) : super(key: key); 16 | 17 | @override 18 | _WeatherNightStarBgState createState() => _WeatherNightStarBgState(); 19 | } 20 | 21 | class _WeatherNightStarBgState extends State 22 | with SingleTickerProviderStateMixin { 23 | AnimationController _controller; 24 | List<_StarParam> _starParams = []; 25 | List<_MeteorParam> _meteorParams = []; 26 | WeatherDataState _state = WeatherDataState.init; 27 | double width; 28 | double height; 29 | double widthRatio; 30 | 31 | /// 准备星星的参数信息 32 | void fetchData() async { 33 | Size size = SizeInherited.of(context).size; 34 | width = size.width; 35 | height = size.height; 36 | widthRatio = width / 392.0; 37 | weatherPrint("开始准备星星参数"); 38 | _state = WeatherDataState.loading; 39 | initStarParams(); 40 | setState(() { 41 | _controller.repeat(); 42 | }); 43 | _state = WeatherDataState.finish; 44 | } 45 | 46 | /// 初始化星星参数 47 | void initStarParams() { 48 | for (int i = 0; i < 100; i++) { 49 | var index = Random().nextInt(2); 50 | _StarParam _starParam = _StarParam(index); 51 | _starParam.init(width, height, widthRatio); 52 | _starParams.add(_starParam); 53 | } 54 | for (int i = 0; i < 4; i++) { 55 | _MeteorParam param = _MeteorParam(); 56 | param.init(width, height, widthRatio); 57 | _meteorParams.add(param); 58 | } 59 | } 60 | 61 | @override 62 | void initState() { 63 | /// 初始化动画信息 64 | _controller = 65 | AnimationController(duration: Duration(seconds: 5), vsync: this); 66 | _controller.addListener(() { 67 | setState(() {}); 68 | }); 69 | super.initState(); 70 | } 71 | 72 | @override 73 | void dispose() { 74 | _controller.dispose(); 75 | super.dispose(); 76 | } 77 | 78 | Widget _buildWidget() { 79 | if (_starParams != null && 80 | _starParams.isNotEmpty && 81 | widget.weatherType == WeatherType.sunnyNight) { 82 | return CustomPaint( 83 | painter: 84 | _StarPainter(_starParams, _meteorParams, width, height, widthRatio), 85 | ); 86 | } else { 87 | return Container(); 88 | } 89 | } 90 | 91 | @override 92 | Widget build(BuildContext context) { 93 | if (_state == WeatherDataState.init) { 94 | fetchData(); 95 | } else if (_state == WeatherDataState.finish) { 96 | return _buildWidget(); 97 | } 98 | return Container(); 99 | } 100 | } 101 | 102 | class _StarPainter extends CustomPainter { 103 | final _paint = Paint(); 104 | final _meteorPaint = Paint(); 105 | final List<_StarParam> _starParams; 106 | 107 | final width; 108 | final height; 109 | final widthRatio; 110 | 111 | /// 配置星星数据信息 112 | final List<_MeteorParam> _meteorParams; 113 | 114 | /// 流星参数信息 115 | final double _meteorWidth = 200; 116 | 117 | /// 流星的长度 118 | final double _meteorHeight = 2; 119 | 120 | /// 流星的高度 121 | final Radius _radius = Radius.circular(10); 122 | 123 | /// 流星的圆角半径 124 | _StarPainter(this._starParams, this._meteorParams, this.width, this.height, 125 | this.widthRatio) { 126 | _paint.maskFilter = MaskFilter.blur(BlurStyle.normal, 1); 127 | _paint.color = Colors.white; 128 | _paint.style = PaintingStyle.fill; 129 | } 130 | 131 | @override 132 | void paint(Canvas canvas, Size size) { 133 | if (_starParams != null && _starParams.isNotEmpty) { 134 | for (var param in _starParams) { 135 | drawStar(param, canvas); 136 | } 137 | } 138 | if (_meteorParams != null && _meteorParams.isNotEmpty) { 139 | for (var param in _meteorParams) { 140 | drawMeteor(param, canvas); 141 | } 142 | } 143 | } 144 | 145 | /// 绘制流星 146 | void drawMeteor(_MeteorParam param, Canvas canvas) { 147 | canvas.save(); 148 | var gradient = ui.Gradient.linear( 149 | const Offset(0, 0), 150 | Offset(_meteorWidth, 0), 151 | [const Color(0xFFFFFFFF), const Color(0x00FFFFFF)], 152 | ); 153 | _meteorPaint.shader = gradient; 154 | canvas.rotate(pi * param.radians); 155 | canvas.scale(widthRatio); 156 | canvas.translate( 157 | param.translateX, tan(pi * 0.1) * _meteorWidth + param.translateY); 158 | canvas.drawRRect( 159 | RRect.fromLTRBAndCorners(0, 0, _meteorWidth, _meteorHeight, 160 | topLeft: _radius, 161 | topRight: _radius, 162 | bottomRight: _radius, 163 | bottomLeft: _radius), 164 | _meteorPaint); 165 | param.move(); 166 | canvas.restore(); 167 | } 168 | 169 | /// 绘制星星 170 | void drawStar(_StarParam param, Canvas canvas) { 171 | if (param == null) { 172 | return; 173 | } 174 | canvas.save(); 175 | var identity = ColorFilter.matrix([ 176 | 1, 177 | 0, 178 | 0, 179 | 0, 180 | 0, 181 | 0, 182 | 1, 183 | 0, 184 | 0, 185 | 0, 186 | 0, 187 | 0, 188 | 1, 189 | 0, 190 | 0, 191 | 0, 192 | 0, 193 | 0, 194 | param.alpha, 195 | 0, 196 | ]); 197 | _paint.colorFilter = identity; 198 | canvas.scale(param.scale); 199 | canvas.drawCircle(Offset(param.x, param.y), 3, _paint); 200 | canvas.restore(); 201 | param.move(); 202 | } 203 | 204 | @override 205 | bool shouldRepaint(CustomPainter oldDelegate) { 206 | return true; 207 | } 208 | } 209 | 210 | class _MeteorParam { 211 | double translateX; 212 | double translateY; 213 | double radians; 214 | 215 | double width, height, widthRatio; 216 | 217 | /// 初始化数据 218 | void init(width, height, widthRatio) { 219 | this.width = width; 220 | this.height = height; 221 | this.widthRatio = widthRatio; 222 | reset(); 223 | } 224 | 225 | /// 重置数据 226 | void reset() { 227 | translateX = width + Random().nextDouble() * 20.0 * width; 228 | radians = -Random().nextDouble() * 0.07 - 0.05; 229 | translateY = Random().nextDouble() * 0.5 * height * widthRatio; 230 | } 231 | 232 | /// 移动 233 | void move() { 234 | translateX -= 20; 235 | if (translateX <= -1.0 * width / widthRatio) { 236 | reset(); 237 | } 238 | } 239 | } 240 | 241 | class _StarParam { 242 | /// x 坐标 243 | double x; 244 | 245 | /// y 坐标 246 | double y; 247 | 248 | /// 透明度值,默认为 0 249 | double alpha = 0.0; 250 | 251 | /// 缩放 252 | double scale; 253 | 254 | /// 是否反向动画 255 | bool reverse = false; 256 | 257 | /// 当前下标值 258 | int index; 259 | 260 | double width; 261 | 262 | double height; 263 | 264 | double widthRatio; 265 | 266 | _StarParam(this.index); 267 | 268 | void reset() { 269 | alpha = 0; 270 | double baseScale = index == 0 ? 0.7 : 0.5; 271 | scale = (Random().nextDouble() * 0.1 + baseScale) * widthRatio; 272 | x = Random().nextDouble() * 1 * width / scale; 273 | y = Random().nextDouble() * max(0.3 * height, 150); 274 | reverse = false; 275 | } 276 | 277 | /// 用于初始参数 278 | void init(width, height, widthRatio) { 279 | this.width = width; 280 | this.height = height; 281 | this.widthRatio = widthRatio; 282 | alpha = Random().nextDouble(); 283 | double baseScale = index == 0 ? 0.7 : 0.5; 284 | scale = (Random().nextDouble() * 0.1 + baseScale) * widthRatio; 285 | x = Random().nextDouble() * 1 * width / scale; 286 | y = Random().nextDouble() * max(0.3 * height, 150); 287 | reverse = false; 288 | } 289 | 290 | /// 每次绘制完会触发此方法,开始移动 291 | void move() { 292 | if (reverse == true) { 293 | alpha -= 0.01; 294 | if (alpha < 0) { 295 | reset(); 296 | } 297 | } else { 298 | alpha += 0.01; 299 | if (alpha > 1.2) { 300 | reverse = true; 301 | } 302 | } 303 | } 304 | } 305 | -------------------------------------------------------------------------------- /lib/bg/weather_rain_snow_bg.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 5 | import 'package:flutter_weather_bg/utils/image_utils.dart'; 6 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 7 | import 'dart:ui' as ui; 8 | 9 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 10 | 11 | //// 雨雪动画层 12 | class WeatherRainSnowBg extends StatefulWidget { 13 | final WeatherType weatherType; 14 | final double viewWidth; 15 | final double viewHeight; 16 | 17 | WeatherRainSnowBg( 18 | {Key key, this.weatherType, this.viewWidth, this.viewHeight}) 19 | : super(key: key); 20 | 21 | @override 22 | _WeatherRainSnowBgState createState() => _WeatherRainSnowBgState(); 23 | } 24 | 25 | class _WeatherRainSnowBgState extends State 26 | with SingleTickerProviderStateMixin { 27 | List _images = []; 28 | AnimationController _controller; 29 | List _rainSnows = []; 30 | int count = 0; 31 | WeatherDataState _state; 32 | 33 | /// 异步获取雨雪的图片资源和初始化数据 34 | Future fetchImages() async { 35 | weatherPrint("开始获取雨雪图片"); 36 | var image1 = await ImageUtils.getImage('images/rain.webp'); 37 | var image2 = await ImageUtils.getImage('images/snow.webp'); 38 | _images.clear(); 39 | _images.add(image1); 40 | _images.add(image2); 41 | weatherPrint("获取雨雪图片成功: ${_images?.length}"); 42 | _state = WeatherDataState.init; 43 | setState(() {}); 44 | } 45 | 46 | /// 初始化雨雪参数 47 | Future initParams() async { 48 | _state = WeatherDataState.loading; 49 | if (widget.viewWidth != 0 && widget.viewHeight != 0 && _rainSnows.isEmpty) { 50 | weatherPrint( 51 | "开始雨参数初始化 ${_rainSnows.length}, weatherType: ${widget.weatherType}, isRainy: ${WeatherUtil.isRainy(widget.weatherType)}"); 52 | if (WeatherUtil.isSnowRain(widget.weatherType)) { 53 | if (widget.weatherType == WeatherType.lightRainy) { 54 | count = 70; 55 | } else if (widget.weatherType == WeatherType.middleRainy) { 56 | count = 100; 57 | } else if (widget.weatherType == WeatherType.heavyRainy || 58 | widget.weatherType == WeatherType.thunder) { 59 | count = 200; 60 | } else if (widget.weatherType == WeatherType.lightSnow) { 61 | count = 30; 62 | } else if (widget.weatherType == WeatherType.middleSnow) { 63 | count = 100; 64 | } else if (widget.weatherType == WeatherType.heavySnow) { 65 | count = 200; 66 | } 67 | var widthRatio = SizeInherited.of(context).size.width / 392.0; 68 | var heightRatio = SizeInherited.of(context).size.height / 817; 69 | for (int i = 0; i < count; i++) { 70 | var rainSnow = RainSnowParams( 71 | widget.viewWidth, widget.viewHeight, widget.weatherType); 72 | rainSnow.init(widthRatio, heightRatio); 73 | _rainSnows.add(rainSnow); 74 | } 75 | weatherPrint("初始化雨参数成功 ${_rainSnows.length}"); 76 | } 77 | } 78 | _controller.forward(); 79 | _state = WeatherDataState.finish; 80 | } 81 | 82 | @override 83 | void didUpdateWidget(WeatherRainSnowBg oldWidget) { 84 | super.didUpdateWidget(oldWidget); 85 | if (oldWidget.weatherType != widget.weatherType || 86 | oldWidget.viewWidth != widget.viewWidth || 87 | oldWidget.viewHeight != widget.viewHeight) { 88 | _rainSnows.clear(); 89 | initParams(); 90 | } 91 | } 92 | 93 | @override 94 | void initState() { 95 | _controller = 96 | AnimationController(duration: Duration(minutes: 1), vsync: this); 97 | CurvedAnimation(parent: _controller, curve: Curves.linear); 98 | _controller.addListener(() { 99 | setState(() {}); 100 | }); 101 | _controller.addStatusListener((status) { 102 | if (status == AnimationStatus.completed) { 103 | _controller.repeat(); 104 | } 105 | }); 106 | fetchImages(); 107 | super.initState(); 108 | } 109 | 110 | @override 111 | void dispose() { 112 | _controller.dispose(); 113 | super.dispose(); 114 | } 115 | 116 | @override 117 | Widget build(BuildContext context) { 118 | if (_state == WeatherDataState.init) { 119 | initParams(); 120 | } else if (_state == WeatherDataState.finish) { 121 | return CustomPaint( 122 | painter: RainSnowPainter(this), 123 | ); 124 | } 125 | return Container(); 126 | } 127 | } 128 | 129 | class RainSnowPainter extends CustomPainter { 130 | var _paint = Paint(); 131 | _WeatherRainSnowBgState _state; 132 | 133 | RainSnowPainter(this._state); 134 | 135 | @override 136 | void paint(Canvas canvas, Size size) { 137 | if (WeatherUtil.isSnow(_state.widget.weatherType)) { 138 | drawSnow(canvas, size); 139 | } else if (WeatherUtil.isRainy(_state.widget.weatherType)) { 140 | drawRain(canvas, size); 141 | } 142 | } 143 | 144 | void drawRain(Canvas canvas, Size size) { 145 | if (_state._images != null && _state._images.length > 1) { 146 | ui.Image image = _state._images[0]; 147 | if (_state._rainSnows != null && _state._rainSnows.isNotEmpty) { 148 | _state._rainSnows.forEach((element) { 149 | move(element); 150 | ui.Offset offset = ui.Offset(element.x, element.y); 151 | canvas.save(); 152 | canvas.scale(element.scale); 153 | var identity = ColorFilter.matrix([ 154 | 1, 155 | 0, 156 | 0, 157 | 0, 158 | 0, 159 | 0, 160 | 1, 161 | 0, 162 | 0, 163 | 0, 164 | 0, 165 | 0, 166 | 1, 167 | 0, 168 | 0, 169 | 0, 170 | 0, 171 | 0, 172 | element.alpha, 173 | 0, 174 | ]); 175 | _paint.colorFilter = identity; 176 | canvas.drawImage(image, offset, _paint); 177 | canvas.restore(); 178 | }); 179 | } 180 | } 181 | } 182 | 183 | void move(RainSnowParams params) { 184 | params.y = params.y + params.speed; 185 | if (WeatherUtil.isSnow(_state.widget.weatherType)) { 186 | double offsetX = sin(params.y / (300 + 50 * params.alpha)) * 187 | (1 + 0.5 * params.alpha) * 188 | params.widthRatio; 189 | params.x += offsetX; 190 | } 191 | if (params.y > params.height / params.scale) { 192 | params.y = -params.height * params.scale; 193 | if (WeatherUtil.isRainy(_state.widget.weatherType) && 194 | _state._images.isNotEmpty && 195 | _state._images[0] != null) { 196 | params.y = -_state._images[0].height.toDouble(); 197 | } 198 | params.reset(); 199 | } 200 | } 201 | 202 | void drawSnow(Canvas canvas, Size size) { 203 | if (_state._images != null && _state._images.length > 1) { 204 | ui.Image image = _state._images[1]; 205 | if (_state._rainSnows != null && _state._rainSnows.isNotEmpty) { 206 | _state._rainSnows.forEach((element) { 207 | move(element); 208 | ui.Offset offset = ui.Offset(element.x, element.y); 209 | canvas.save(); 210 | canvas.scale(element.scale, element.scale); 211 | var identity = ColorFilter.matrix([ 212 | 1, 213 | 0, 214 | 0, 215 | 0, 216 | 0, 217 | 0, 218 | 1, 219 | 0, 220 | 0, 221 | 0, 222 | 0, 223 | 0, 224 | 1, 225 | 0, 226 | 0, 227 | 0, 228 | 0, 229 | 0, 230 | element.alpha, 231 | 0, 232 | ]); 233 | _paint.colorFilter = identity; 234 | canvas.drawImage(image, offset, _paint); 235 | canvas.restore(); 236 | }); 237 | } 238 | } 239 | } 240 | 241 | @override 242 | bool shouldRepaint(CustomPainter oldDelegate) { 243 | return true; 244 | } 245 | } 246 | 247 | class RainSnowParams { 248 | /// x 坐标 249 | double x; 250 | 251 | /// y 坐标 252 | double y; 253 | 254 | /// 下落速度 255 | double speed; 256 | 257 | /// 绘制的缩放 258 | double scale; 259 | 260 | /// 宽度 261 | double width; 262 | 263 | /// 高度 264 | double height; 265 | 266 | /// 透明度 267 | double alpha; 268 | 269 | /// 天气类型 270 | WeatherType weatherType; 271 | 272 | double widthRatio; 273 | double heightRatio; 274 | 275 | RainSnowParams(this.width, this.height, this.weatherType); 276 | 277 | void init(widthRatio, heightRatio) { 278 | this.widthRatio = widthRatio; 279 | this.heightRatio = max(heightRatio, 0.65); 280 | 281 | /// 雨 0.1 雪 0.5 282 | reset(); 283 | y = Random().nextInt(800 ~/ scale).toDouble(); 284 | } 285 | 286 | /// 当雪花移出屏幕时,需要重置参数 287 | void reset() { 288 | double ratio = 1.0; 289 | 290 | if (weatherType == WeatherType.lightRainy) { 291 | ratio = 0.5; 292 | } else if (weatherType == WeatherType.middleRainy) { 293 | ratio = 0.75; 294 | } else if (weatherType == WeatherType.heavyRainy || 295 | weatherType == WeatherType.thunder) { 296 | ratio = 1; 297 | } else if (weatherType == WeatherType.lightSnow) { 298 | ratio = 0.5; 299 | } else if (weatherType == WeatherType.middleSnow) { 300 | ratio = 0.75; 301 | } else if (weatherType == WeatherType.heavySnow) { 302 | ratio = 1; 303 | } 304 | if (WeatherUtil.isRainy(weatherType)) { 305 | double random = 0.4 + 0.12 * Random().nextDouble() * 5; 306 | this.scale = random * 1.2; 307 | this.speed = 30 * random * ratio * heightRatio; 308 | this.alpha = random * 0.6; 309 | x = Random().nextInt(width * 1.2 ~/ scale).toDouble() - 310 | width * 0.1 ~/ scale; 311 | } else { 312 | double random = 0.4 + 0.12 * Random().nextDouble() * 5; 313 | this.scale = random * 0.8 * heightRatio; 314 | this.speed = 8 * random * ratio * heightRatio; 315 | this.alpha = random; 316 | x = Random().nextInt(width * 1.2 ~/ scale).toDouble() - 317 | width * 0.1 ~/ scale; 318 | } 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /lib/bg/weather_thunder_bg.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_weather_bg/bg/weather_bg.dart'; 5 | import 'dart:ui' as ui; 6 | 7 | import 'package:flutter_weather_bg/utils/image_utils.dart'; 8 | import 'package:flutter_weather_bg/utils/print_utils.dart'; 9 | import 'package:flutter_weather_bg/utils/weather_type.dart'; 10 | 11 | /// 雷暴动画层 12 | class WeatherThunderBg extends StatefulWidget { 13 | final WeatherType weatherType; 14 | 15 | WeatherThunderBg({Key key, this.weatherType}) : super(key: key); 16 | 17 | @override 18 | _WeatherCloudBgState createState() => _WeatherCloudBgState(); 19 | } 20 | 21 | class _WeatherCloudBgState extends State 22 | with SingleTickerProviderStateMixin { 23 | List _images = []; 24 | AnimationController _controller; 25 | List _thunderParams = []; 26 | WeatherDataState _state; 27 | 28 | /// 异步获取雷暴图片资源 29 | Future fetchImages() async { 30 | weatherPrint("开始获取雷暴图片"); 31 | var image1 = await ImageUtils.getImage('images/lightning0.webp'); 32 | var image2 = await ImageUtils.getImage('images/lightning1.webp'); 33 | var image3 = await ImageUtils.getImage('images/lightning2.webp'); 34 | var image4 = await ImageUtils.getImage('images/lightning3.webp'); 35 | var image5 = await ImageUtils.getImage('images/lightning4.webp'); 36 | _images.add(image1); 37 | _images.add(image2); 38 | _images.add(image3); 39 | _images.add(image4); 40 | _images.add(image5); 41 | weatherPrint("获取雷暴图片成功: ${_images?.length}"); 42 | _state = WeatherDataState.init; 43 | setState(() {}); 44 | } 45 | 46 | @override 47 | void initState() { 48 | fetchImages(); 49 | initAnim(); 50 | super.initState(); 51 | } 52 | 53 | // 这里用于初始化动画相关,将闪电三个作为一组循环播放展示 54 | void initAnim() { 55 | _controller = 56 | AnimationController(duration: Duration(seconds: 3), vsync: this); 57 | _controller.addStatusListener((status) { 58 | if (status == AnimationStatus.completed) { 59 | _controller.reset(); 60 | Future.delayed(Duration(milliseconds: 50)).then((value) { 61 | initThunderParams(); 62 | _controller.forward(); 63 | }); 64 | } 65 | }); 66 | 67 | // 构造第一个闪电的动画数据 68 | var _animation = TweenSequence([ 69 | TweenSequenceItem( 70 | tween: Tween(begin: 0.0, end: 1.0) 71 | .chain(CurveTween(curve: Curves.easeIn)), 72 | weight: 1), 73 | TweenSequenceItem( 74 | tween: Tween(begin: 1.0, end: 0.0) 75 | .chain(CurveTween(curve: Curves.easeIn)), 76 | weight: 3), 77 | ]).animate(CurvedAnimation( 78 | parent: _controller, 79 | curve: Interval( 80 | 0.0, 81 | 0.3, 82 | curve: Curves.ease, 83 | ), 84 | )); 85 | 86 | // 构造第二个闪电的动画数据 87 | var _animation1 = TweenSequence([ 88 | TweenSequenceItem( 89 | tween: Tween(begin: 0.0, end: 1.0) 90 | .chain(CurveTween(curve: Curves.easeIn)), 91 | weight: 1), 92 | TweenSequenceItem( 93 | tween: Tween(begin: 1.0, end: 0.0) 94 | .chain(CurveTween(curve: Curves.easeIn)), 95 | weight: 3), 96 | ]).animate(CurvedAnimation( 97 | parent: _controller, 98 | curve: Interval( 99 | 0.2, 100 | 0.5, 101 | curve: Curves.ease, 102 | ), 103 | )); 104 | 105 | // 构造第三个闪电的动画数据 106 | var _animation2 = TweenSequence([ 107 | TweenSequenceItem( 108 | tween: Tween(begin: 0.0, end: 1.0) 109 | .chain(CurveTween(curve: Curves.easeIn)), 110 | weight: 1), 111 | TweenSequenceItem( 112 | tween: Tween(begin: 1.0, end: 0.0) 113 | .chain(CurveTween(curve: Curves.easeIn)), 114 | weight: 3), 115 | ]).animate(CurvedAnimation( 116 | parent: _controller, 117 | curve: Interval( 118 | 0.6, 119 | 0.9, 120 | curve: Curves.ease, 121 | ), 122 | )); 123 | 124 | _animation.addListener(() { 125 | if (_thunderParams != null && _thunderParams.isNotEmpty) { 126 | _thunderParams[0].alpha = _animation.value; 127 | } 128 | setState(() {}); 129 | }); 130 | 131 | _animation1.addListener(() { 132 | if (_thunderParams != null && _thunderParams.isNotEmpty) { 133 | _thunderParams[1].alpha = _animation1.value; 134 | } 135 | setState(() {}); 136 | }); 137 | 138 | _animation2.addListener(() { 139 | if (_thunderParams != null && _thunderParams.isNotEmpty) { 140 | _thunderParams[2].alpha = _animation2.value; 141 | } 142 | setState(() {}); 143 | }); 144 | } 145 | 146 | @override 147 | void dispose() { 148 | _controller.dispose(); 149 | super.dispose(); 150 | } 151 | 152 | /// 构建雷暴 widget 153 | Widget _buildWidget() { 154 | // 这里需要判断天气类别信息,防止不需要绘制的时候绘制,影响性能 155 | if (_thunderParams != null && 156 | _thunderParams.isNotEmpty && 157 | widget.weatherType == WeatherType.thunder) { 158 | return CustomPaint( 159 | painter: ThunderPainter(_thunderParams), 160 | ); 161 | } else { 162 | return Container(); 163 | } 164 | } 165 | 166 | /// 初始化雷暴参数 167 | void initThunderParams() { 168 | _state = WeatherDataState.loading; 169 | _thunderParams.clear(); 170 | var size = SizeInherited.of(context).size; 171 | var width = size.width; 172 | var height = size.height; 173 | var widthRatio = size.width / 392.0; 174 | // 配置三个闪电信息 175 | for (var i = 0; i < 3; i++) { 176 | var param = ThunderParams( 177 | _images[Random().nextInt(5)], width, height, widthRatio); 178 | param.reset(); 179 | _thunderParams.add(param); 180 | } 181 | _controller.forward(); 182 | _state = WeatherDataState.finish; 183 | } 184 | 185 | @override 186 | Widget build(BuildContext context) { 187 | if (_state == WeatherDataState.init) { 188 | initThunderParams(); 189 | } else if (_state == WeatherDataState.finish) { 190 | return _buildWidget(); 191 | } 192 | return Container(); 193 | } 194 | } 195 | 196 | class ThunderPainter extends CustomPainter { 197 | var _paint = Paint(); 198 | final List thunderParams; 199 | 200 | ThunderPainter(this.thunderParams); 201 | 202 | @override 203 | void paint(Canvas canvas, Size size) { 204 | if (thunderParams != null && thunderParams.isNotEmpty) { 205 | for (var param in thunderParams) { 206 | drawThunder(param, canvas, size); 207 | } 208 | } 209 | } 210 | 211 | /// 这里主要负责绘制雷电 212 | void drawThunder(ThunderParams params, Canvas canvas, Size size) { 213 | if (params == null || params.image == null) { 214 | return; 215 | } 216 | canvas.save(); 217 | var identity = ColorFilter.matrix([ 218 | 1, 219 | 0, 220 | 0, 221 | 0, 222 | 0, 223 | 0, 224 | 1, 225 | 0, 226 | 0, 227 | 0, 228 | 0, 229 | 0, 230 | 1, 231 | 0, 232 | 0, 233 | 0, 234 | 0, 235 | 0, 236 | params.alpha, 237 | 0, 238 | ]); 239 | _paint.colorFilter = identity; 240 | canvas.scale(params.widthRatio * 1.2); 241 | canvas.drawImage(params.image, Offset(params.x, params.y), _paint); 242 | canvas.restore(); 243 | } 244 | 245 | @override 246 | bool shouldRepaint(CustomPainter oldDelegate) { 247 | return false; 248 | } 249 | } 250 | 251 | class ThunderParams { 252 | ui.Image image; // 配置闪电的图片资源 253 | double x; // 图片展示的 x 坐标 254 | double y; // 图片展示的 y 坐标 255 | double alpha; // 闪电的 alpha 属性 256 | int get imgWidth => image.width; // 雷电图片的宽度 257 | int get imgHeight => image.height; // 雷电图片的高度 258 | final double width, height, widthRatio; 259 | 260 | ThunderParams(this.image, this.width, this.height, this.widthRatio); 261 | 262 | // 重置图片的位置信息 263 | void reset() { 264 | x = Random().nextDouble() * 0.5 * widthRatio - 1 / 3 * imgWidth; 265 | y = Random().nextDouble() * -0.05 * height; 266 | alpha = 0; 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /lib/flutter_weather_bg.dart: -------------------------------------------------------------------------------- 1 | library flutter_weather_bg; 2 | 3 | export 'package:flutter_weather_bg/utils/weather_type.dart'; 4 | export 'package:flutter_weather_bg/bg/weather_bg.dart' hide WeatherItemBg; 5 | -------------------------------------------------------------------------------- /lib/utils/image_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | import 'dart:ui' as ui; 3 | import 'dart:typed_data'; 4 | 5 | import 'package:flutter/services.dart'; 6 | 7 | /// 图片相关的工具类 8 | class ImageUtils { 9 | /// 绘制时需要用到 ui.Image 的对象,通过此方法进行转换 10 | static Future getImage(String asset) async { 11 | ByteData data = await rootBundle.load("packages/flutter_weather_bg/$asset"); 12 | Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); 13 | FrameInfo fi = await codec.getNextFrame(); 14 | return fi.image; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/utils/print_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | /// 定义打印函数 4 | typedef WeatherPrint = void Function(String message, 5 | {int wrapWidth, String tag}); 6 | 7 | const DEBUG = true; 8 | 9 | WeatherPrint weatherPrint = debugPrintThrottled; 10 | 11 | // 统一方法进行打印 12 | void debugPrintThrottled(String message, {int wrapWidth, String tag}) { 13 | if (DEBUG) { 14 | debugPrint("flutter-weather: $tag: $message", wrapWidth: wrapWidth); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/utils/weather_type.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | /// 目前有15种天气类型 4 | enum WeatherType { 5 | heavyRainy, 6 | heavySnow, 7 | middleSnow, 8 | thunder, 9 | lightRainy, 10 | lightSnow, 11 | sunnyNight, 12 | sunny, 13 | cloudy, 14 | cloudyNight, 15 | middleRainy, 16 | overcast, 17 | hazy, // 霾 18 | foggy, // 雾 19 | dusty, // 浮尘 20 | } 21 | 22 | /// 数据加载状态 23 | enum WeatherDataState { 24 | /// 初始化 25 | init, 26 | 27 | /// 正在加载 28 | loading, 29 | 30 | /// 加载结束 31 | finish, 32 | } 33 | 34 | /// 天气的相关工具类 35 | class WeatherUtil { 36 | static bool isSnowRain(WeatherType weatherType) { 37 | return isRainy(weatherType) || isSnow(weatherType); 38 | } 39 | 40 | /// 判断是否下雨,小中大包括雷暴,都是属于雨的类型 41 | static bool isRainy(WeatherType weatherType) { 42 | return weatherType == WeatherType.lightRainy || 43 | weatherType == WeatherType.middleRainy || 44 | weatherType == WeatherType.heavyRainy || 45 | weatherType == WeatherType.thunder; 46 | } 47 | 48 | /// 判断是否下雪 49 | static bool isSnow(WeatherType weatherType) { 50 | return weatherType == WeatherType.lightSnow || 51 | weatherType == WeatherType.middleSnow || 52 | weatherType == WeatherType.heavySnow; 53 | } 54 | 55 | // 根据天气类型获取背景的颜色值 56 | static List getColor(WeatherType weatherType) { 57 | switch (weatherType) { 58 | case WeatherType.sunny: 59 | return [Color(0xFF0071D1), Color(0xFF6DA6E4)]; 60 | case WeatherType.sunnyNight: 61 | return [Color(0xFF061E74), Color(0xFF275E9A)]; 62 | case WeatherType.cloudy: 63 | return [Color(0xFF5C82C1), Color(0xFF95B1DB)]; 64 | case WeatherType.cloudyNight: 65 | return [Color(0xFF2C3A60), Color(0xFF4B6685)]; 66 | case WeatherType.overcast: 67 | return [Color(0xFF8FA3C0), Color(0xFF8C9FB1)]; 68 | case WeatherType.lightRainy: 69 | return [Color(0xFF556782), Color(0xFF7c8b99)]; 70 | case WeatherType.middleRainy: 71 | return [Color(0xFF3A4B65), Color(0xFF495764)]; 72 | case WeatherType.heavyRainy: 73 | case WeatherType.thunder: 74 | return [Color(0xFF3B434E), Color(0xFF565D66)]; 75 | case WeatherType.hazy: 76 | return [Color(0xFF989898), Color(0xFF4B4B4B)]; 77 | case WeatherType.foggy: 78 | return [Color(0xFFA6B3C2), Color(0xFF737F88)]; 79 | case WeatherType.lightSnow: 80 | return [Color(0xFF6989BA), Color(0xFF9DB0CE)]; 81 | case WeatherType.middleSnow: 82 | return [Color(0xFF8595AD), Color(0xFF95A4BF)]; 83 | case WeatherType.heavySnow: 84 | return [Color(0xFF98A2BC), Color(0xFFA7ADBF)]; 85 | case WeatherType.dusty: 86 | return [Color(0xFFB99D79), Color(0xFF6C5635)]; 87 | default: 88 | return [Color(0xFF0071D1), Color(0xFF6DA6E4)]; 89 | } 90 | } 91 | 92 | // 根据天气类型获取天气的描述信息 93 | static String getWeatherDesc(WeatherType weatherType) { 94 | switch (weatherType) { 95 | case WeatherType.sunny: 96 | case WeatherType.sunnyNight: 97 | return "晴"; 98 | case WeatherType.cloudy: 99 | case WeatherType.cloudyNight: 100 | return "多云"; 101 | case WeatherType.overcast: 102 | return "阴"; 103 | case WeatherType.lightRainy: 104 | return "小雨"; 105 | case WeatherType.middleRainy: 106 | return "中雨"; 107 | case WeatherType.heavyRainy: 108 | return "大雨"; 109 | case WeatherType.thunder: 110 | return "雷阵雨"; 111 | case WeatherType.hazy: 112 | return "雾"; 113 | case WeatherType.foggy: 114 | return "霾"; 115 | case WeatherType.lightSnow: 116 | return "小雪"; 117 | case WeatherType.middleSnow: 118 | return "中雪"; 119 | case WeatherType.heavySnow: 120 | return "大雪"; 121 | case WeatherType.dusty: 122 | return "浮尘"; 123 | default: 124 | return "晴"; 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.4.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.0.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.0.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.1.3" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.0.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "1.14.13" 46 | fake_async: 47 | dependency: transitive 48 | description: 49 | name: fake_async 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "1.1.0" 53 | flutter: 54 | dependency: "direct main" 55 | description: flutter 56 | source: sdk 57 | version: "0.0.0" 58 | flutter_test: 59 | dependency: "direct dev" 60 | description: flutter 61 | source: sdk 62 | version: "0.0.0" 63 | matcher: 64 | dependency: transitive 65 | description: 66 | name: matcher 67 | url: "https://pub.flutter-io.cn" 68 | source: hosted 69 | version: "0.12.8" 70 | meta: 71 | dependency: transitive 72 | description: 73 | name: meta 74 | url: "https://pub.flutter-io.cn" 75 | source: hosted 76 | version: "1.1.8" 77 | path: 78 | dependency: transitive 79 | description: 80 | name: path 81 | url: "https://pub.flutter-io.cn" 82 | source: hosted 83 | version: "1.7.0" 84 | sky_engine: 85 | dependency: transitive 86 | description: flutter 87 | source: sdk 88 | version: "0.0.99" 89 | source_span: 90 | dependency: transitive 91 | description: 92 | name: source_span 93 | url: "https://pub.flutter-io.cn" 94 | source: hosted 95 | version: "1.7.0" 96 | stack_trace: 97 | dependency: transitive 98 | description: 99 | name: stack_trace 100 | url: "https://pub.flutter-io.cn" 101 | source: hosted 102 | version: "1.9.5" 103 | stream_channel: 104 | dependency: transitive 105 | description: 106 | name: stream_channel 107 | url: "https://pub.flutter-io.cn" 108 | source: hosted 109 | version: "2.0.0" 110 | string_scanner: 111 | dependency: transitive 112 | description: 113 | name: string_scanner 114 | url: "https://pub.flutter-io.cn" 115 | source: hosted 116 | version: "1.0.5" 117 | term_glyph: 118 | dependency: transitive 119 | description: 120 | name: term_glyph 121 | url: "https://pub.flutter-io.cn" 122 | source: hosted 123 | version: "1.1.0" 124 | test_api: 125 | dependency: transitive 126 | description: 127 | name: test_api 128 | url: "https://pub.flutter-io.cn" 129 | source: hosted 130 | version: "0.2.17" 131 | typed_data: 132 | dependency: transitive 133 | description: 134 | name: typed_data 135 | url: "https://pub.flutter-io.cn" 136 | source: hosted 137 | version: "1.2.0" 138 | vector_math: 139 | dependency: transitive 140 | description: 141 | name: vector_math 142 | url: "https://pub.flutter-io.cn" 143 | source: hosted 144 | version: "2.0.8" 145 | sdks: 146 | dart: ">=2.9.0-14.0.dev <3.0.0" 147 | flutter: ">=1.20.0 <2.0.0" 148 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_weather_bg 2 | description: Provide a variety of weather background animation effects, covering 15 weather types, including sunny,rain,snow... 3 | version: 2.8.2 4 | homepage: https://github.com/xiaweizi/flutter_weather_bg 5 | 6 | environment: 7 | sdk: ">=2.7.0 <3.0.0" 8 | flutter: ">=1.20.0 <2.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | # For information on the generic Dart part of this file, see the 19 | # following page: https://dart.dev/tools/pub/pubspec 20 | 21 | # The following section is specific to Flutter. 22 | flutter: 23 | # This section identifies this Flutter project as a plugin project. 24 | # The 'pluginClass' and Android 'package' identifiers should not ordinarily 25 | # be modified. They are used by the tooling to maintain consistency when 26 | # adding or updating assets for this project. 27 | # plugin: 28 | # platforms: 29 | # android: 30 | # package: com.example.flutter_weather_bg 31 | # pluginClass: FlutterWeatherBgPlugin 32 | # ios: 33 | # pluginClass: FlutterWeatherBgPlugin 34 | 35 | # To add assets to your plugin package, add an assets section, like this: 36 | assets: 37 | - images/ 38 | # - images/a_dot_burr.jpeg 39 | # - images/a_dot_ham.jpeg 40 | # 41 | # For details regarding assets in packages, see 42 | # https://flutter.dev/assets-and-images/#from-packages 43 | # 44 | # An image asset can refer to one or more resolution-specific "variants", see 45 | # https://flutter.dev/assets-and-images/#resolution-aware. 46 | 47 | # To add custom fonts to your plugin package, add a fonts section here, 48 | # in this "flutter" section. Each entry in this list should have a 49 | # "family" key with the font family name, and a "fonts" key with a 50 | # list giving the asset and other descriptors for the font. For 51 | # example: 52 | # fonts: 53 | # - family: Schyler 54 | # fonts: 55 | # - asset: fonts/Schyler-Regular.ttf 56 | # - asset: fonts/Schyler-Italic.ttf 57 | # style: italic 58 | # - family: Trajan Pro 59 | # fonts: 60 | # - asset: fonts/TrajanPro.ttf 61 | # - asset: fonts/TrajanPro_Bold.ttf 62 | # weight: 700 63 | # 64 | # For details regarding fonts in packages, see 65 | # https://flutter.dev/custom-fonts/#from-packages 66 | -------------------------------------------------------------------------------- /test/flutter_weather_bg_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:flutter_weather_bg/flutter_weather_bg.dart'; 4 | 5 | void main() { 6 | const MethodChannel channel = MethodChannel('flutter_weather_bg'); 7 | 8 | TestWidgetsFlutterBinding.ensureInitialized(); 9 | 10 | setUp(() { 11 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 12 | return '42'; 13 | }); 14 | }); 15 | 16 | tearDown(() { 17 | channel.setMockMethodCallHandler(null); 18 | }); 19 | 20 | } 21 | --------------------------------------------------------------------------------