├── .gitattributes
├── .gitignore
├── .metadata
├── LICENSE
├── README.md
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── flutter_weather
│ │ │ │ └── MainActivity.kt
│ │ └── res
│ │ │ ├── drawable-v21
│ │ │ └── launch_background.xml
│ │ │ ├── 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-night
│ │ │ └── styles.xml
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── assets
└── images
│ ├── Cloud.png
│ ├── Cloudy.png
│ ├── Fog.png
│ ├── Rainy.png
│ ├── Snow.png
│ ├── Storm.png
│ ├── StormWindy.png
│ ├── Sunny.png
│ ├── locError.png
│ ├── requestError.png
│ └── searchError.png
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── 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.swift
│ ├── 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
│ └── Runner-Bridging-Header.h
├── lib
├── Screens
│ └── homeScreen.dart
├── helper
│ ├── extensions.dart
│ └── utils.dart
├── main.dart
├── models
│ ├── additionalWeatherData.dart
│ ├── dailyWeather.dart
│ ├── geocode.dart
│ ├── hourlyWeather.dart
│ └── weather.dart
├── provider
│ └── weatherProvider.dart
├── screens
│ ├── locationError.dart
│ ├── requestError.dart
│ └── sevenDayForecastDetailScreen.dart
├── theme
│ ├── colors.dart
│ └── textStyle.dart
└── widgets
│ ├── WeatherInfoHeader.dart
│ ├── customShimmer.dart
│ ├── fadeIn.dart
│ ├── locationError.dart
│ ├── mainWeatherDetail.dart
│ ├── mainWeatherInfo.dart
│ ├── requestError.dart
│ ├── sevenDayForecast.dart
│ └── twentyFourHourForecast.dart
├── linux
├── .gitignore
├── CMakeLists.txt
├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
├── main.cc
├── my_application.cc
└── my_application.h
├── macos
├── .gitignore
├── Flutter
│ ├── Flutter-Debug.xcconfig
│ ├── Flutter-Release.xcconfig
│ └── GeneratedPluginRegistrant.swift
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── app_icon_1024.png
│ │ ├── app_icon_128.png
│ │ ├── app_icon_16.png
│ │ ├── app_icon_256.png
│ │ ├── app_icon_32.png
│ │ ├── app_icon_512.png
│ │ └── app_icon_64.png
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Configs
│ ├── AppInfo.xcconfig
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── Warnings.xcconfig
│ ├── DebugProfile.entitlements
│ ├── Info.plist
│ ├── MainFlutterWindow.swift
│ └── Release.entitlements
├── pubspec.lock
├── pubspec.yaml
├── test
└── widget_test.dart
├── web
├── favicon.png
├── icons
│ ├── Icon-192.png
│ ├── Icon-512.png
│ ├── Icon-maskable-192.png
│ └── Icon-maskable-512.png
├── index.html
└── manifest.json
└── windows
├── .gitignore
├── CMakeLists.txt
├── flutter
├── CMakeLists.txt
├── generated_plugin_registrant.cc
├── generated_plugin_registrant.h
└── generated_plugins.cmake
└── runner
├── CMakeLists.txt
├── Runner.rc
├── flutter_window.cpp
├── flutter_window.h
├── main.cpp
├── resource.h
├── resources
└── app_icon.ico
├── runner.exe.manifest
├── utils.cpp
├── utils.h
├── win32_window.cpp
└── win32_window.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.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.
5 |
6 | version:
7 | revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
8 | channel: stable
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
17 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
18 | - platform: android
19 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
20 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
21 | - platform: ios
22 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
23 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
24 | - platform: linux
25 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
26 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
27 | - platform: macos
28 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
29 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
30 | - platform: web
31 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
32 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
33 | - platform: windows
34 | create_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
35 | base_revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
36 |
37 | # User provided section
38 |
39 | # List of Local paths (relative to this file) that should be
40 | # ignored by the migrate tool.
41 | #
42 | # Files that are not part of the templates will be ignored by default.
43 | unmanaged_files:
44 | - 'lib/main.dart'
45 | - 'ios/Runner.xcodeproj/project.pbxproj'
46 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Ariz Armeidi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, 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,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FlutterWeather
2 | ### Updated to Flutter 3.0 & New Updated Design
3 |
4 | A simple weather App created using [Flutter](https://flutter.dev/) and [Dart](https://dart.dev/) and using API from [OpenWeatherMap](https://openweathermap.org/)
5 | **New Design Inspired by [Rina Damayanti](https://dribbble.com/shots/23103004-Weather-Mobile-App) on Dribbble.**
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | ## API Docs
15 | > [!IMPORTANT]
16 | > This project uses **_version 2.5_** of the OpenWeatherMap API
17 | > **API used in this project**:
18 | > - [Current Weather API Docs](https://openweathermap.org/current#one)
19 | > - [One Call API Docs](https://openweathermap.org/api/one-call-api#data)
20 | > - [Geocoding API Docs](https://openweathermap.org/api/geocoding-api)
21 |
22 |
23 | ## Features
24 | - Automatically acquire user current location
25 | - Searchable location
26 | - Hourly weather information
27 | - 7 days weather information
28 |
29 |
30 | ## How to Run
31 | 1. Create an account at [OpenWeatherMap](https://openweathermap.org/).
32 | 2. Then get your API key from https://home.openweathermap.org/api_keys.
33 | >Sometimes after getting your OpenWeatherMap API key it won't work right away
34 | >To test if your API key is working or not copy and paste the following link to your browser
35 | >https://api.openweathermap.org/data/2.5/weather?lat=53.4794892&lon=-2.2451148&units=metric&appid=YOUR_API_KEY
36 | >Then replace `YOUR_API_KEY` with your own API key from OpenWeatherMap
37 | 3. Clone the repo
38 | ```sh
39 | git clone https://github.com/ArizArmeidi/FlutterWeather.git
40 | ```
41 | 4. Install all the packages by typing
42 | ```sh
43 | flutter pub get
44 | ```
45 | 5. Navigate to **lib/provider/weatherProvider.dart** and paste your API key to the apiKey variable
46 | ```dart
47 | String apiKey = 'Paste Your API Key Here';
48 | ```
49 | 6. Run the App
50 |
51 | ## Contact
52 | - [Ariz Armeidi](https://github.com/ArizArmeidi/) | [Twitter](https://twitter.com/ArizArmeidi) | [Instagram](https://www.instagram.com/ariz.armeidi/)
53 | - If you find the content of this repository useful and you have some extra money, you can donate to me through [PayPal](https://www.paypal.com/paypalme/arizarmeidi)
54 |
55 | ## License
56 | Distributed under the MIT License. See `LICENSE` for more information.
57 |
--------------------------------------------------------------------------------
/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 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/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 plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 33
30 | ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47 | applicationId "com.example.flutter_weather"
48 | // You can update the following values to match your application needs.
49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
50 | minSdkVersion flutter.minSdkVersion
51 | targetSdkVersion flutter.targetSdkVersion
52 | versionCode flutterVersionCode.toInteger()
53 | versionName flutterVersionName
54 | }
55 |
56 | buildTypes {
57 | release {
58 | // TODO: Add your own signing config for the release build.
59 | // Signing with the debug keys for now, so `flutter run --release` works.
60 | signingConfig signingConfigs.debug
61 | }
62 | }
63 | }
64 |
65 | flutter {
66 | source '../..'
67 | }
68 |
69 | dependencies {
70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71 | }
72 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
10 |
18 |
22 |
26 |
27 |
28 |
29 |
30 |
31 |
33 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/example/flutter_weather/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.flutter_weather
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.9.22'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.1.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | tasks.register("clean", Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
17 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
18 | def properties = new Properties()
19 |
20 | assert localPropertiesFile.exists()
21 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
22 |
23 | def flutterSdkPath = properties.getProperty("flutter.sdk")
24 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
25 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
26 |
--------------------------------------------------------------------------------
/assets/images/Cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Cloud.png
--------------------------------------------------------------------------------
/assets/images/Cloudy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Cloudy.png
--------------------------------------------------------------------------------
/assets/images/Fog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Fog.png
--------------------------------------------------------------------------------
/assets/images/Rainy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Rainy.png
--------------------------------------------------------------------------------
/assets/images/Snow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Snow.png
--------------------------------------------------------------------------------
/assets/images/Storm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Storm.png
--------------------------------------------------------------------------------
/assets/images/StormWindy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/StormWindy.png
--------------------------------------------------------------------------------
/assets/images/Sunny.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/Sunny.png
--------------------------------------------------------------------------------
/assets/images/locError.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/locError.png
--------------------------------------------------------------------------------
/assets/images/requestError.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/requestError.png
--------------------------------------------------------------------------------
/assets/images/searchError.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/assets/images/searchError.png
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
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 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Flutter Weather
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | flutter_weather
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 | CADisableMinimumFrameDurationOnPhone
47 |
48 | UIApplicationSupportsIndirectInputEvents
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/lib/Screens/homeScreen.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_weather/screens/locationError.dart';
4 | import 'package:geolocator/geolocator.dart';
5 | import 'package:material_floating_search_bar_2/material_floating_search_bar_2.dart';
6 | import 'package:phosphor_flutter/phosphor_flutter.dart';
7 | import 'package:provider/provider.dart';
8 |
9 | import '../provider/weatherProvider.dart';
10 | import '../theme/colors.dart';
11 | import '../theme/textStyle.dart';
12 | import '../widgets/WeatherInfoHeader.dart';
13 | import '../widgets/mainWeatherDetail.dart';
14 | import '../widgets/mainWeatherInfo.dart';
15 | import '../widgets/sevenDayForecast.dart';
16 | import '../widgets/twentyFourHourForecast.dart';
17 |
18 | import 'requestError.dart';
19 |
20 | class HomeScreen extends StatefulWidget {
21 | const HomeScreen({Key? key}) : super(key: key);
22 |
23 | @override
24 | State createState() => _HomeScreenState();
25 | }
26 |
27 | class _HomeScreenState extends State {
28 | FloatingSearchBarController fsc = FloatingSearchBarController();
29 |
30 | @override
31 | void initState() {
32 | super.initState();
33 | requestWeather();
34 | }
35 |
36 | Future requestWeather() async {
37 | await Provider.of(context, listen: false)
38 | .getWeatherData(context);
39 | }
40 |
41 | @override
42 | Widget build(BuildContext context) {
43 | return Scaffold(
44 | body: Consumer(
45 | builder: (context, weatherProv, _) {
46 | if (!weatherProv.isLoading && !weatherProv.isLocationserviceEnabled)
47 | return LocationServiceErrorDisplay();
48 |
49 | if (!weatherProv.isLoading &&
50 | weatherProv.locationPermission != LocationPermission.always &&
51 | weatherProv.locationPermission != LocationPermission.whileInUse) {
52 | return LocationPermissionErrorDisplay();
53 | }
54 |
55 | if (weatherProv.isRequestError) return RequestErrorDisplay();
56 |
57 | if (weatherProv.isSearchError) return SearchErrorDisplay(fsc: fsc);
58 |
59 | return Stack(
60 | children: [
61 | ListView(
62 | physics: BouncingScrollPhysics(),
63 | padding: const EdgeInsets.all(12.0).copyWith(
64 | top: kToolbarHeight +
65 | MediaQuery.viewPaddingOf(context).top +
66 | 24.0,
67 | ),
68 | children: [
69 | WeatherInfoHeader(),
70 | const SizedBox(height: 16.0),
71 | MainWeatherInfo(),
72 | const SizedBox(height: 16.0),
73 | MainWeatherDetail(),
74 | const SizedBox(height: 24.0),
75 | TwentyFourHourForecast(),
76 | const SizedBox(height: 18.0),
77 | SevenDayForecast(),
78 | ],
79 | ),
80 | CustomSearchBar(fsc: fsc),
81 | ],
82 | );
83 | },
84 | ),
85 | );
86 | }
87 | }
88 |
89 | class CustomSearchBar extends StatefulWidget {
90 | final FloatingSearchBarController fsc;
91 | const CustomSearchBar({
92 | Key? key,
93 | required this.fsc,
94 | }) : super(key: key);
95 |
96 | @override
97 | State createState() => _CustomSearchBarState();
98 | }
99 |
100 | class _CustomSearchBarState extends State {
101 | List _citiesSuggestion = [
102 | 'New York',
103 | 'Tokyo',
104 | 'Dubai',
105 | 'London',
106 | 'Singapore',
107 | 'Sydney',
108 | 'Wellington'
109 | ];
110 |
111 | @override
112 | Widget build(BuildContext context) {
113 | return FloatingSearchBar(
114 | controller: widget.fsc,
115 | hint: 'Search...',
116 | clearQueryOnClose: false,
117 | scrollPadding: const EdgeInsets.only(top: 16.0, bottom: 56.0),
118 | transitionDuration: const Duration(milliseconds: 400),
119 | borderRadius: BorderRadius.circular(16.0),
120 | transitionCurve: Curves.easeInOut,
121 | accentColor: primaryBlue,
122 | hintStyle: regularText,
123 | queryStyle: regularText,
124 | physics: const BouncingScrollPhysics(),
125 | elevation: 2.0,
126 | debounceDelay: const Duration(milliseconds: 500),
127 | onQueryChanged: (query) {},
128 | onSubmitted: (query) async {
129 | widget.fsc.close();
130 | await Provider.of(context, listen: false)
131 | .searchWeather(query);
132 | },
133 | transition: CircularFloatingSearchBarTransition(),
134 | actions: [
135 | FloatingSearchBarAction(
136 | showIfOpened: false,
137 | child: PhosphorIcon(
138 | PhosphorIconsBold.magnifyingGlass,
139 | color: primaryBlue,
140 | ),
141 | ),
142 | FloatingSearchBarAction.icon(
143 | showIfClosed: false,
144 | showIfOpened: true,
145 | icon: PhosphorIcon(
146 | PhosphorIconsBold.x,
147 | color: primaryBlue,
148 | ),
149 | onTap: () {
150 | if (widget.fsc.query.isEmpty) {
151 | widget.fsc.close();
152 | } else {
153 | widget.fsc.clear();
154 | }
155 | },
156 | ),
157 | ],
158 | builder: (context, transition) {
159 | return ClipRRect(
160 | borderRadius: BorderRadius.circular(8.0),
161 | child: Material(
162 | color: Colors.white,
163 | elevation: 4.0,
164 | child: ListView.separated(
165 | shrinkWrap: true,
166 | physics: BouncingScrollPhysics(),
167 | padding: EdgeInsets.zero,
168 | itemCount: _citiesSuggestion.length,
169 | itemBuilder: (context, index) {
170 | String data = _citiesSuggestion[index];
171 | return InkWell(
172 | onTap: () async {
173 | widget.fsc.query = data;
174 | widget.fsc.close();
175 | await Provider.of(context, listen: false)
176 | .searchWeather(data);
177 | },
178 | child: Container(
179 | padding: const EdgeInsets.all(22.0),
180 | child: Row(
181 | children: [
182 | PhosphorIcon(PhosphorIconsFill.mapPin),
183 | const SizedBox(width: 22.0),
184 | Text(data, style: mediumText),
185 | ],
186 | ),
187 | ),
188 | );
189 | },
190 | separatorBuilder: (context, index) => Divider(
191 | thickness: 1.0,
192 | height: 0.0,
193 | ),
194 | ),
195 | ),
196 | );
197 | },
198 | );
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/lib/helper/extensions.dart:
--------------------------------------------------------------------------------
1 | extension StringCasingExtension on String {
2 | String toCapitalized() =>
3 | length > 0 ? '${this[0].toUpperCase()}${substring(1).toLowerCase()}' : '';
4 | String toTitleCase() => replaceAll(RegExp(' +'), ' ')
5 | .split(' ')
6 | .map((str) => str.toCapitalized())
7 | .join(' ');
8 | }
9 |
10 | extension DoubleExtension on double {
11 | double toFahrenheit() => (this * 1.8 + 32).toDouble();
12 | }
13 |
--------------------------------------------------------------------------------
/lib/helper/utils.dart:
--------------------------------------------------------------------------------
1 | String uviValueToString(double uvi) {
2 | if (uvi <= 2) {
3 | return 'Low';
4 | } else if (uvi <= 5) {
5 | return 'Medium';
6 | } else if (uvi <= 7) {
7 | return 'High';
8 | } else if (uvi <= 10) {
9 | return 'Very High';
10 | } else if (uvi >= 11) {
11 | return 'Extreme';
12 | }
13 | return 'Unknown';
14 | }
15 |
16 | String getWeatherImage(String input) {
17 | String weather = input.toLowerCase();
18 | String assetPath = 'assets/images/';
19 | switch (weather) {
20 | case 'thunderstorm':
21 | return assetPath + 'Storm.png';
22 |
23 | case 'drizzle':
24 | case 'rain':
25 | return assetPath + 'Rainy.png';
26 |
27 | case 'snow':
28 | return assetPath + 'Snow.png';
29 |
30 | case 'clear':
31 | return assetPath + 'Sunny.png';
32 |
33 | case 'clouds':
34 | return assetPath + 'Cloudy.png';
35 |
36 | case 'mist':
37 | case 'fog':
38 | case 'smoke':
39 | case 'haze':
40 | case 'dust':
41 | case 'sand':
42 | case 'ash':
43 | return assetPath + 'Fog.png';
44 |
45 | case 'squall':
46 | case 'tornado':
47 | return assetPath + 'StormWindy.png';
48 |
49 | default:
50 | return assetPath + 'Cloud.png';
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:provider/provider.dart';
4 |
5 | import './provider/weatherProvider.dart';
6 | import 'screens/homeScreen.dart';
7 | import 'screens/sevenDayForecastDetailScreen.dart';
8 |
9 | void main() {
10 | runApp(
11 | MyApp(),
12 | );
13 | }
14 |
15 | class MyApp extends StatelessWidget {
16 | @override
17 | Widget build(BuildContext context) {
18 | return ChangeNotifierProvider(
19 | create: (context) => WeatherProvider(),
20 | child: MaterialApp(
21 | title: 'Flutter Weather',
22 | debugShowCheckedModeBanner: false,
23 | theme: ThemeData(
24 | appBarTheme: AppBarTheme(
25 | backgroundColor: Colors.white,
26 | iconTheme: IconThemeData(color: Colors.blue),
27 | elevation: 0,
28 | ),
29 | scaffoldBackgroundColor: Colors.white,
30 | primaryColor: Colors.blue,
31 | visualDensity: VisualDensity.adaptivePlatformDensity,
32 | colorScheme:
33 | ColorScheme.fromSwatch().copyWith(secondary: Colors.white),
34 | ),
35 | home: HomeScreen(),
36 | // routes: {
37 | // WeeklyScreen.routeName: (ctx) => WeeklyScreen(),
38 | // },
39 | onGenerateRoute: (settings) {
40 | final arguments = settings.arguments;
41 | if (settings.name == SevenDayForecastDetail.routeName) {
42 | return PageRouteBuilder(
43 | settings: settings,
44 | pageBuilder: (_, __, ___) => SevenDayForecastDetail(
45 | initialIndex: arguments == null ? 0 : arguments as int,
46 | ),
47 | transitionsBuilder: (ctx, a, b, c) => CupertinoPageTransition(
48 | primaryRouteAnimation: a,
49 | secondaryRouteAnimation: b,
50 | linearTransition: false,
51 | child: c,
52 | ),
53 | );
54 | }
55 | // Unknown route
56 | return MaterialPageRoute(builder: (_) => HomeScreen());
57 | },
58 | ),
59 | );
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/lib/models/additionalWeatherData.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | class AdditionalWeatherData {
3 | final String precipitation;
4 | final double uvi;
5 | final int clouds;
6 | AdditionalWeatherData({
7 | required this.precipitation,
8 | required this.uvi,
9 | required this.clouds,
10 | });
11 |
12 | factory AdditionalWeatherData.fromJson(Map json) {
13 | final precipData = json['daily'][0]['pop'];
14 | final precip = (precipData * 100).toStringAsFixed(0);
15 | return AdditionalWeatherData(
16 | precipitation: precip,
17 | uvi: (json['daily'][0]['uvi']).toDouble(),
18 | clouds: json['daily'][0]['clouds'] ?? 0,
19 | );
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/models/dailyWeather.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | import 'package:flutter/cupertino.dart';
3 |
4 | class DailyWeather with ChangeNotifier {
5 | final double temp;
6 | final double tempMin;
7 | final double tempMax;
8 | final double tempMorning;
9 | final double tempDay;
10 | final double tempEvening;
11 | final double tempNight;
12 | final String weatherCategory;
13 | final String condition;
14 | final DateTime date;
15 | final String precipitation;
16 | final double uvi;
17 | final int clouds;
18 | final int humidity;
19 |
20 | DailyWeather({
21 | required this.temp,
22 | required this.tempMin,
23 | required this.tempMax,
24 | required this.tempMorning,
25 | required this.tempDay,
26 | required this.tempEvening,
27 | required this.tempNight,
28 | required this.weatherCategory,
29 | required this.condition,
30 | required this.date,
31 | required this.precipitation,
32 | required this.uvi,
33 | required this.clouds,
34 | required this.humidity,
35 | });
36 |
37 | static DailyWeather fromDailyJson(dynamic json) {
38 | return DailyWeather(
39 | temp: (json['temp']['day']).toDouble(),
40 | tempMin: (json['temp']['min']).toDouble(),
41 | tempMax: (json['temp']['max']).toDouble(),
42 | tempMorning: (json['feels_like']['morn']).toDouble(),
43 | tempDay: (json['feels_like']['day']).toDouble(),
44 | tempEvening: (json['feels_like']['eve']).toDouble(),
45 | tempNight: (json['feels_like']['night']).toDouble(),
46 | weatherCategory: json['weather'][0]['main'],
47 | condition: json['weather'][0]['description'],
48 | date: DateTime.fromMillisecondsSinceEpoch(json['dt'] * 1000, isUtc: true),
49 | precipitation: ((json['pop']).toDouble() * 100).toStringAsFixed(0),
50 | clouds: json['clouds'],
51 | humidity: json['humidity'],
52 | uvi: (json['uvi']).toDouble(),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/lib/models/geocode.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | import 'package:latlong2/latlong.dart';
3 |
4 | class GeocodeData {
5 | String name;
6 | LatLng latLng;
7 | GeocodeData({
8 | required this.name,
9 | required this.latLng,
10 | });
11 |
12 | factory GeocodeData.fromJson(Map json) {
13 | return GeocodeData(
14 | name: json['name'],
15 | latLng: LatLng(json['lat'], json['lon']),
16 | );
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/models/hourlyWeather.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | class HourlyWeather {
3 | final double temp;
4 | final String weatherCategory;
5 | final String? condition;
6 | final DateTime date;
7 |
8 | HourlyWeather({
9 | required this.temp,
10 | required this.weatherCategory,
11 | this.condition,
12 | required this.date,
13 | });
14 |
15 | static HourlyWeather fromJson(dynamic json) {
16 | return HourlyWeather(
17 | temp: (json['temp']).toDouble(),
18 | weatherCategory: json['weather'][0]['main'],
19 | condition: json['weather'][0]['description'],
20 | date: DateTime.fromMillisecondsSinceEpoch(json['dt'] * 1000),
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/models/weather.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | import 'package:flutter/cupertino.dart';
3 |
4 | class Weather with ChangeNotifier {
5 | final double temp;
6 | final double tempMax;
7 | final double tempMin;
8 | final double lat;
9 | final double long;
10 | final double feelsLike;
11 | final int pressure;
12 | final String description;
13 | final String weatherCategory;
14 | final int humidity;
15 | final double windSpeed;
16 | String city;
17 | final String countryCode;
18 |
19 | Weather({
20 | required this.temp,
21 | required this.tempMax,
22 | required this.tempMin,
23 | required this.lat,
24 | required this.long,
25 | required this.feelsLike,
26 | required this.pressure,
27 | required this.description,
28 | required this.weatherCategory,
29 | required this.humidity,
30 | required this.windSpeed,
31 | required this.city,
32 | required this.countryCode,
33 | });
34 |
35 | factory Weather.fromJson(Map json) {
36 | return Weather(
37 | temp: (json['main']['temp']).toDouble(),
38 | tempMax: (json['main']['temp_max']).toDouble(),
39 | tempMin: (json['main']['temp_min']).toDouble(),
40 | lat: json['coord']['lat'],
41 | long: json['coord']['lon'],
42 | feelsLike: (json['main']['feels_like']).toDouble(),
43 | pressure: json['main']['pressure'],
44 | weatherCategory: json['weather'][0]['main'],
45 | description: json['weather'][0]['description'],
46 | humidity: json['main']['humidity'],
47 | windSpeed: (json['wind']['speed']).toDouble(),
48 | city: json['name'],
49 | countryCode: json['sys']['country'],
50 | );
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/lib/provider/weatherProvider.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_weather/models/additionalWeatherData.dart';
5 | import 'package:flutter_weather/models/geocode.dart';
6 | import 'package:geolocator/geolocator.dart';
7 | import 'package:http/http.dart' as http;
8 | import 'package:latlong2/latlong.dart';
9 |
10 | import '../models/dailyWeather.dart';
11 | import '../models/hourlyWeather.dart';
12 | import '../models/weather.dart';
13 |
14 | class WeatherProvider with ChangeNotifier {
15 | String apiKey = 'Enter Your API Key';
16 | late Weather weather;
17 | late AdditionalWeatherData additionalWeatherData;
18 | LatLng? currentLocation;
19 | List hourlyWeather = [];
20 | List dailyWeather = [];
21 | bool isLoading = false;
22 | bool isRequestError = false;
23 | bool isSearchError = false;
24 | bool isLocationserviceEnabled = false;
25 | LocationPermission? locationPermission;
26 | bool isCelsius = true;
27 |
28 | String get measurementUnit => isCelsius ? '°C' : '°F';
29 |
30 | Future requestLocation(BuildContext context) async {
31 | isLocationserviceEnabled = await Geolocator.isLocationServiceEnabled();
32 | notifyListeners();
33 |
34 | if (!isLocationserviceEnabled) {
35 | ScaffoldMessenger.of(context).showSnackBar(
36 | SnackBar(content: Text('Location service disabled')),
37 | );
38 | return Future.error('Location services are disabled.');
39 | }
40 |
41 | locationPermission = await Geolocator.checkPermission();
42 | if (locationPermission == LocationPermission.denied) {
43 | isLoading = false;
44 | notifyListeners();
45 | locationPermission = await Geolocator.requestPermission();
46 | if (locationPermission == LocationPermission.denied) {
47 | ScaffoldMessenger.of(context).showSnackBar(SnackBar(
48 | content: Text('Permission denied'),
49 | ));
50 | return Future.error('Location permissions are denied');
51 | }
52 | }
53 |
54 | if (locationPermission == LocationPermission.deniedForever) {
55 | isLoading = false;
56 | notifyListeners();
57 | ScaffoldMessenger.of(context).showSnackBar(SnackBar(
58 | content: Text(
59 | 'Location permissions are permanently denied, Please enable manually from app settings',
60 | ),
61 | ));
62 | return Future.error('Location permissions are permanently denied');
63 | }
64 |
65 | return await Geolocator.getCurrentPosition();
66 | }
67 |
68 | Future getWeatherData(
69 | BuildContext context, {
70 | bool notify = false,
71 | }) async {
72 | isLoading = true;
73 | isRequestError = false;
74 | isSearchError = false;
75 | if (notify) notifyListeners();
76 |
77 | Position? locData = await requestLocation(context);
78 |
79 | if (locData == null) {
80 | isLoading = false;
81 | notifyListeners();
82 | return;
83 | }
84 |
85 | try {
86 | currentLocation = LatLng(locData.latitude, locData.longitude);
87 | await getCurrentWeather(currentLocation!);
88 | await getDailyWeather(currentLocation!);
89 | } catch (e) {
90 | print(e);
91 | isRequestError = true;
92 | } finally {
93 | isLoading = false;
94 | notifyListeners();
95 | }
96 | }
97 |
98 | Future getCurrentWeather(LatLng location) async {
99 | Uri url = Uri.parse(
100 | 'https://api.openweathermap.org/data/2.5/weather?lat=${location.latitude}&lon=${location.longitude}&units=metric&appid=$apiKey',
101 | );
102 | try {
103 | final response = await http.get(url);
104 | final extractedData = json.decode(response.body) as Map;
105 | weather = Weather.fromJson(extractedData);
106 | print('Fetched Weather for: ${weather.city}/${weather.countryCode}');
107 | } catch (error) {
108 | print(error);
109 | isLoading = false;
110 | this.isRequestError = true;
111 | }
112 | }
113 |
114 | Future getDailyWeather(LatLng location) async {
115 | isLoading = true;
116 | notifyListeners();
117 |
118 | Uri dailyUrl = Uri.parse(
119 | 'https://api.openweathermap.org/data/2.5/onecall?lat=${location.latitude}&lon=${location.longitude}&units=metric&exclude=minutely,current&appid=$apiKey',
120 | );
121 | try {
122 | final response = await http.get(dailyUrl);
123 | final dailyData = json.decode(response.body) as Map;
124 | additionalWeatherData = AdditionalWeatherData.fromJson(dailyData);
125 | List dailyList = dailyData['daily'];
126 | List hourlyList = dailyData['hourly'];
127 | hourlyWeather = hourlyList
128 | .map((item) => HourlyWeather.fromJson(item))
129 | .toList()
130 | .take(24)
131 | .toList();
132 | dailyWeather =
133 | dailyList.map((item) => DailyWeather.fromDailyJson(item)).toList();
134 | } catch (error) {
135 | print(error);
136 | isLoading = false;
137 | this.isRequestError = true;
138 | }
139 | }
140 |
141 | Future locationToLatLng(String location) async {
142 | try {
143 | Uri url = Uri.parse(
144 | 'http://api.openweathermap.org/geo/1.0/direct?q=$location&limit=5&appid=$apiKey',
145 | );
146 | final http.Response response = await http.get(url);
147 | if (response.statusCode != 200) return null;
148 | return GeocodeData.fromJson(
149 | jsonDecode(response.body)[0] as Map,
150 | );
151 | } catch (e) {
152 | print(e);
153 | return null;
154 | }
155 | }
156 |
157 | Future searchWeather(String location) async {
158 | isLoading = true;
159 | notifyListeners();
160 | isRequestError = false;
161 | print('search');
162 | try {
163 | GeocodeData? geocodeData;
164 | geocodeData = await locationToLatLng(location);
165 | if (geocodeData == null) throw Exception('Unable to Find Location');
166 | await getCurrentWeather(geocodeData.latLng);
167 | await getDailyWeather(geocodeData.latLng);
168 | // replace location name with data from geocode
169 | // because data from certain lat long might return local area name
170 | weather.city = geocodeData.name;
171 | } catch (e) {
172 | print(e);
173 | isSearchError = true;
174 | } finally {
175 | isLoading = false;
176 | notifyListeners();
177 | }
178 | }
179 |
180 | void switchTempUnit() {
181 | isCelsius = !isCelsius;
182 | notifyListeners();
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/lib/screens/locationError.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_weather/theme/colors.dart';
5 | import 'package:geolocator/geolocator.dart';
6 | import 'package:provider/provider.dart';
7 |
8 | import '../provider/weatherProvider.dart';
9 | import '../theme/textStyle.dart';
10 |
11 | class LocationPermissionErrorDisplay extends StatelessWidget {
12 | const LocationPermissionErrorDisplay({Key? key}) : super(key: key);
13 |
14 | @override
15 | Widget build(BuildContext context) {
16 | return Consumer(builder: (context, weatherProv, _) {
17 | return Padding(
18 | padding: const EdgeInsets.all(12.0),
19 | child: Column(
20 | mainAxisAlignment: MainAxisAlignment.center,
21 | crossAxisAlignment: CrossAxisAlignment.center,
22 | children: [
23 | ConstrainedBox(
24 | constraints: BoxConstraints(
25 | maxWidth: MediaQuery.sizeOf(context).width,
26 | minWidth: 100,
27 | maxHeight: MediaQuery.sizeOf(context).height / 3,
28 | ),
29 | child: Image.asset('assets/images/locError.png'),
30 | ),
31 | Center(
32 | child: Text(
33 | 'Location Permission Error',
34 | style: boldText.copyWith(color: primaryBlue),
35 | ),
36 | ),
37 | const SizedBox(height: 4.0),
38 | Center(
39 | child: Text(
40 | weatherProv.locationPermission ==
41 | LocationPermission.deniedForever
42 | ? 'Location permissions are permanently denied, Please enable manually from app settings and restart the app'
43 | : 'Location permission not granted, please check your location permission',
44 | style: mediumText.copyWith(color: Colors.grey.shade700),
45 | textAlign: TextAlign.center,
46 | ),
47 | ),
48 | const SizedBox(height: 16.0),
49 | SizedBox(
50 | width: MediaQuery.sizeOf(context).width / 2,
51 | child: Column(
52 | children: [
53 | ElevatedButton(
54 | style: ElevatedButton.styleFrom(
55 | backgroundColor: primaryBlue,
56 | textStyle: mediumText,
57 | padding: const EdgeInsets.all(12.0),
58 | shape: StadiumBorder(),
59 | ),
60 | child: weatherProv.isLoading
61 | ? const SizedBox(
62 | width: 16.0,
63 | height: 16.0,
64 | child: CircularProgressIndicator(
65 | strokeWidth: 3.0,
66 | color: Colors.white,
67 | ),
68 | )
69 | : Text(
70 | weatherProv.locationPermission ==
71 | LocationPermission.deniedForever
72 | ? 'Open App Settings'
73 | : 'Request Permission',
74 | ),
75 | onPressed: weatherProv.isLoading
76 | ? null
77 | : () async {
78 | if (weatherProv.locationPermission ==
79 | LocationPermission.deniedForever) {
80 | await Geolocator.openAppSettings();
81 | } else {
82 | weatherProv.getWeatherData(context, notify: true);
83 | }
84 | },
85 | ),
86 | const SizedBox(height: 4.0),
87 | if (weatherProv.locationPermission ==
88 | LocationPermission.deniedForever)
89 | TextButton(
90 | style: TextButton.styleFrom(foregroundColor: primaryBlue),
91 | child: Text('Restart'),
92 | onPressed: weatherProv.isLoading
93 | ? null
94 | : () =>
95 | weatherProv.getWeatherData(context, notify: true),
96 | )
97 | ],
98 | ),
99 | ),
100 | ],
101 | ),
102 | );
103 | });
104 | }
105 | }
106 |
107 | class LocationServiceErrorDisplay extends StatefulWidget {
108 | const LocationServiceErrorDisplay({Key? key}) : super(key: key);
109 |
110 | @override
111 | State createState() =>
112 | _LocationServiceErrorDisplayState();
113 | }
114 |
115 | class _LocationServiceErrorDisplayState
116 | extends State {
117 | late StreamSubscription serviceStatusStream;
118 |
119 | @override
120 | void initState() {
121 | super.initState();
122 | serviceStatusStream = Geolocator.getServiceStatusStream().listen((_) {});
123 | serviceStatusStream.onData((ServiceStatus status) {
124 | if (status == ServiceStatus.enabled) {
125 | print('enabled');
126 | Provider.of(context, listen: false)
127 | .getWeatherData(context);
128 | }
129 | });
130 | }
131 |
132 | @override
133 | void dispose() {
134 | serviceStatusStream.cancel();
135 | super.dispose();
136 | }
137 |
138 | @override
139 | Widget build(BuildContext context) {
140 | return Padding(
141 | padding: const EdgeInsets.all(12.0),
142 | child: Column(
143 | mainAxisAlignment: MainAxisAlignment.center,
144 | crossAxisAlignment: CrossAxisAlignment.center,
145 | children: [
146 | ConstrainedBox(
147 | constraints: BoxConstraints(
148 | maxWidth: MediaQuery.sizeOf(context).width,
149 | minWidth: 100,
150 | maxHeight: MediaQuery.sizeOf(context).height / 3,
151 | ),
152 | child: Image.asset('assets/images/locError.png'),
153 | ),
154 | Center(
155 | child: Text(
156 | 'Location Service Disabled',
157 | style: boldText.copyWith(color: primaryBlue),
158 | ),
159 | ),
160 | const SizedBox(height: 4.0),
161 | Center(
162 | child: Text(
163 | 'Your device location service is disabled, please turn it on before continuing',
164 | style: mediumText.copyWith(color: Colors.grey.shade700),
165 | textAlign: TextAlign.center,
166 | ),
167 | ),
168 | const SizedBox(height: 16.0),
169 | Consumer(builder: (context, weatherProv, _) {
170 | return SizedBox(
171 | width: MediaQuery.sizeOf(context).width / 2,
172 | child: ElevatedButton(
173 | style: ElevatedButton.styleFrom(
174 | backgroundColor: primaryBlue,
175 | textStyle: mediumText,
176 | padding: const EdgeInsets.all(12.0),
177 | shape: StadiumBorder(),
178 | ),
179 | child: Text('Turn On Service'),
180 | onPressed: () async {
181 | await Geolocator.openLocationSettings();
182 | },
183 | ),
184 | );
185 | }),
186 | ],
187 | ),
188 | );
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/lib/screens/requestError.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_weather/theme/colors.dart';
3 | import 'package:material_floating_search_bar_2/material_floating_search_bar_2.dart';
4 | import 'package:provider/provider.dart';
5 |
6 | import '../provider/weatherProvider.dart';
7 | import '../theme/textStyle.dart';
8 |
9 | class RequestErrorDisplay extends StatelessWidget {
10 | const RequestErrorDisplay({Key? key}) : super(key: key);
11 |
12 | @override
13 | Widget build(BuildContext context) {
14 | return Padding(
15 | padding: const EdgeInsets.all(12.0),
16 | child: Column(
17 | mainAxisAlignment: MainAxisAlignment.center,
18 | crossAxisAlignment: CrossAxisAlignment.center,
19 | children: [
20 | ConstrainedBox(
21 | constraints: BoxConstraints(
22 | maxWidth: MediaQuery.sizeOf(context).width,
23 | minWidth: 100,
24 | maxHeight: MediaQuery.sizeOf(context).height / 3,
25 | ),
26 | child: Image.asset('assets/images/requestError.png'),
27 | ),
28 | Center(
29 | child: Text(
30 | 'Request Error',
31 | style: boldText.copyWith(color: primaryBlue),
32 | ),
33 | ),
34 | const SizedBox(height: 4.0),
35 | Center(
36 | child: Text(
37 | 'Request error, please check your internet connection',
38 | style: mediumText.copyWith(color: Colors.grey.shade700),
39 | textAlign: TextAlign.center,
40 | ),
41 | ),
42 | const SizedBox(height: 16.0),
43 | Consumer(builder: (context, weatherProv, _) {
44 | return SizedBox(
45 | width: MediaQuery.sizeOf(context).width / 2,
46 | child: ElevatedButton(
47 | style: ElevatedButton.styleFrom(
48 | backgroundColor: primaryBlue,
49 | textStyle: mediumText,
50 | padding: const EdgeInsets.all(12.0),
51 | shape: StadiumBorder(),
52 | ),
53 | child: Text('Return Home'),
54 | onPressed: weatherProv.isLoading
55 | ? null
56 | : () async {
57 | await weatherProv.getWeatherData(
58 | context,
59 | notify: true,
60 | );
61 | },
62 | ),
63 | );
64 | }),
65 | ],
66 | ),
67 | );
68 | }
69 | }
70 |
71 | class SearchErrorDisplay extends StatelessWidget {
72 | const SearchErrorDisplay({
73 | Key? key,
74 | required this.fsc,
75 | }) : super(key: key);
76 |
77 | final FloatingSearchBarController fsc;
78 |
79 | @override
80 | Widget build(BuildContext context) {
81 | return Padding(
82 | padding: const EdgeInsets.all(12.0),
83 | child: Column(
84 | mainAxisAlignment: MainAxisAlignment.center,
85 | crossAxisAlignment: CrossAxisAlignment.center,
86 | children: [
87 | ConstrainedBox(
88 | constraints: BoxConstraints(
89 | maxWidth: MediaQuery.sizeOf(context).width,
90 | minWidth: 100,
91 | maxHeight: MediaQuery.sizeOf(context).height / 3,
92 | ),
93 | child: Image.asset('assets/images/searchError.png'),
94 | ),
95 | Center(
96 | child: Text(
97 | 'Search Error',
98 | style: boldText.copyWith(color: primaryBlue),
99 | ),
100 | ),
101 | const SizedBox(height: 4.0),
102 | Center(
103 | child: Text(
104 | 'Unable to find "${fsc.query}", check for typo or check your internet connection',
105 | style: mediumText.copyWith(color: Colors.grey.shade700),
106 | textAlign: TextAlign.center,
107 | ),
108 | ),
109 | const SizedBox(height: 16.0),
110 | Consumer(builder: (context, weatherProv, _) {
111 | return SizedBox(
112 | width: MediaQuery.sizeOf(context).width / 2,
113 | child: ElevatedButton(
114 | style: ElevatedButton.styleFrom(
115 | backgroundColor: primaryBlue,
116 | textStyle: mediumText,
117 | padding: const EdgeInsets.all(12.0),
118 | shape: StadiumBorder(),
119 | ),
120 | child: Text('Return Home'),
121 | onPressed: weatherProv.isLoading
122 | ? null
123 | : () async {
124 | await weatherProv.getWeatherData(
125 | context,
126 | notify: true,
127 | );
128 | },
129 | ),
130 | );
131 | }),
132 | ],
133 | ),
134 | );
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/lib/theme/colors.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | const Color primaryBlue = Color(0xff81BCF7);
4 | const Color backgroundBlue = Color(0xffCAE5FF);
5 | const Color backgroundWhite = Color(0xffF2F8FF);
6 |
--------------------------------------------------------------------------------
/lib/theme/textStyle.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:google_fonts/google_fonts.dart';
3 |
4 | TextStyle lightText = GoogleFonts.openSans(
5 | fontSize: 12,
6 | fontWeight: FontWeight.w300,
7 | color: Colors.black,
8 | );
9 |
10 | TextStyle regularText = GoogleFonts.openSans(
11 | fontSize: 14,
12 | fontWeight: FontWeight.w400,
13 | color: Colors.black,
14 | );
15 |
16 | TextStyle mediumText = GoogleFonts.openSans(
17 | fontSize: 16,
18 | fontWeight: FontWeight.w500,
19 | color: Colors.black,
20 | );
21 |
22 | TextStyle semiboldText = GoogleFonts.openSans(
23 | fontSize: 18,
24 | fontWeight: FontWeight.w600,
25 | color: Colors.black,
26 | );
27 |
28 | TextStyle boldText = GoogleFonts.openSans(
29 | fontSize: 20,
30 | fontWeight: FontWeight.w700,
31 | color: Colors.black,
32 | );
33 |
34 | TextStyle blackText = GoogleFonts.openSans(
35 | fontSize: 24,
36 | fontWeight: FontWeight.w900,
37 | color: Colors.black,
38 | );
39 |
--------------------------------------------------------------------------------
/lib/widgets/WeatherInfoHeader.dart:
--------------------------------------------------------------------------------
1 | import 'package:country_picker/country_picker.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_weather/provider/weatherProvider.dart';
4 | import 'package:flutter_weather/theme/colors.dart';
5 | import 'package:flutter_weather/theme/textStyle.dart';
6 | import 'package:flutter_weather/widgets/customShimmer.dart';
7 | import 'package:intl/intl.dart';
8 | import 'package:provider/provider.dart';
9 |
10 | class WeatherInfoHeader extends StatelessWidget {
11 | static const double boxWidth = 52.0;
12 | static const double boxHeight = 40.0;
13 | @override
14 | Widget build(BuildContext context) {
15 | return Consumer(
16 | builder: (context, weatherProv, _) {
17 | return Row(
18 | mainAxisAlignment: MainAxisAlignment.spaceBetween,
19 | children: [
20 | weatherProv.isLoading
21 | ? Expanded(
22 | child: CustomShimmer(
23 | height: 48.0,
24 | borderRadius: BorderRadius.circular(8.0),
25 | ),
26 | )
27 | : Expanded(
28 | child: Column(
29 | crossAxisAlignment: CrossAxisAlignment.start,
30 | children: [
31 | FittedBox(
32 | child: RichText(
33 | textAlign: TextAlign.start,
34 | text: TextSpan(
35 | text: weatherProv.weather.city + ', ',
36 | style: semiboldText,
37 | children: [
38 | TextSpan(
39 | text: Country.tryParse(
40 | weatherProv.weather.countryCode)
41 | ?.name,
42 | style: regularText.copyWith(fontSize: 18.0),
43 | ),
44 | ],
45 | ),
46 | ),
47 | ),
48 | const SizedBox(height: 4.0),
49 | FittedBox(
50 | child: Text(
51 | DateFormat('EEEE MMM dd, y hh:mm a')
52 | .format(DateTime.now()),
53 | style: regularText.copyWith(
54 | color: Colors.grey.shade700),
55 | ),
56 | )
57 | ],
58 | ),
59 | ),
60 | const SizedBox(width: 8.0),
61 | ClipRRect(
62 | borderRadius: BorderRadius.circular(12.0),
63 | child: Container(
64 | padding: const EdgeInsets.all(4.0),
65 | color: Colors.grey.shade200,
66 | child: Stack(
67 | children: [
68 | AnimatedSwitcher(
69 | duration: Duration(milliseconds: 150),
70 | transitionBuilder:
71 | (Widget child, Animation animation) {
72 | return SlideTransition(
73 | position: Tween(
74 | begin: weatherProv.isCelsius
75 | ? Offset(1.0, 0.0)
76 | : Offset(-1.0, 0.0),
77 | end: Offset(0.0, 0.0),
78 | ).animate(animation),
79 | child: child,
80 | );
81 | },
82 | child: weatherProv.isCelsius
83 | ? GestureDetector(
84 | key: ValueKey(0),
85 | child: Row(
86 | children: [
87 | Container(
88 | height: boxHeight,
89 | width: boxWidth,
90 | alignment: Alignment.center,
91 | decoration: BoxDecoration(
92 | borderRadius: BorderRadius.circular(8.0),
93 | color: weatherProv.isLoading
94 | ? Colors.grey
95 | : primaryBlue,
96 | ),
97 | ),
98 | Container(
99 | height: boxHeight,
100 | width: boxWidth,
101 | alignment: Alignment.center,
102 | decoration: BoxDecoration(
103 | borderRadius: BorderRadius.circular(8.0),
104 | color: Colors.grey.shade200,
105 | ),
106 | ),
107 | ],
108 | ),
109 | onTap: () => weatherProv.isLoading
110 | ? null
111 | : weatherProv.switchTempUnit(),
112 | )
113 | : GestureDetector(
114 | key: ValueKey(1),
115 | child: Row(
116 | children: [
117 | Container(
118 | height: boxHeight,
119 | width: boxWidth,
120 | alignment: Alignment.center,
121 | decoration: BoxDecoration(
122 | borderRadius: BorderRadius.circular(8.0),
123 | color: Colors.grey.shade200,
124 | ),
125 | ),
126 | Container(
127 | height: boxHeight,
128 | width: boxWidth,
129 | alignment: Alignment.center,
130 | decoration: BoxDecoration(
131 | borderRadius: BorderRadius.circular(8.0),
132 | color: weatherProv.isLoading
133 | ? Colors.grey
134 | : primaryBlue,
135 | ),
136 | ),
137 | ],
138 | ),
139 | onTap: () => weatherProv.switchTempUnit(),
140 | ),
141 | ),
142 | IgnorePointer(
143 | child: Row(
144 | children: [
145 | Container(
146 | height: boxHeight,
147 | width: boxWidth,
148 | alignment: Alignment.center,
149 | child: Text(
150 | '°C',
151 | style: semiboldText.copyWith(
152 | fontSize: 16,
153 | color: weatherProv.isCelsius
154 | ? Colors.white
155 | : Colors.grey.shade600,
156 | ),
157 | ),
158 | ),
159 | Container(
160 | height: boxHeight,
161 | width: boxWidth,
162 | alignment: Alignment.center,
163 | child: Text(
164 | '°F',
165 | style: semiboldText.copyWith(
166 | fontSize: 16,
167 | color: weatherProv.isCelsius
168 | ? Colors.grey.shade600
169 | : Colors.white,
170 | ),
171 | ),
172 | ),
173 | ],
174 | ),
175 | ),
176 | ],
177 | ),
178 | ),
179 | )
180 | ],
181 | );
182 | },
183 | );
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/lib/widgets/customShimmer.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | import 'package:flutter/material.dart';
3 | import 'package:shimmer/shimmer.dart';
4 |
5 | class CustomShimmer extends StatelessWidget {
6 | final double height;
7 | final double width;
8 | final BorderRadius? borderRadius;
9 | const CustomShimmer({
10 | Key? key,
11 | this.height = 32.0,
12 | this.width = 32.0,
13 | this.borderRadius,
14 | }) : super(key: key);
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Shimmer.fromColors(
19 | baseColor: Colors.grey.shade300,
20 | highlightColor: Colors.grey.shade100,
21 | child: Container(
22 | decoration: BoxDecoration(
23 | color: Colors.white,
24 | borderRadius: borderRadius,
25 | ),
26 | height: height,
27 | width: width,
28 | ),
29 | );
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lib/widgets/fadeIn.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/widgets.dart';
4 |
5 | class FadeIn extends StatefulWidget {
6 | /// Fade-in controller
7 | final FadeInController? controller;
8 |
9 | /// Child widget to fade-in
10 | final Widget? child;
11 |
12 | /// Duration of fade-in. Defaults to 250ms
13 | final Duration duration;
14 |
15 | /// Fade-in curve. Defaults to [Curves.easeIn]
16 | final Curve curve;
17 |
18 | const FadeIn({
19 | Key? key,
20 | this.controller,
21 | this.child,
22 | this.duration = const Duration(milliseconds: 250),
23 | this.curve = Curves.easeIn,
24 | }) : super(key: key);
25 |
26 | @override
27 | _FadeInState createState() => _FadeInState();
28 | }
29 |
30 | enum FadeInAction {
31 | fadeIn,
32 | fadeOut,
33 | }
34 |
35 | /// Fade-in controller which dispatches fade-in/fade-out actions
36 | class FadeInController {
37 | final _streamController = StreamController();
38 |
39 | /// Automatically starts the initial fade-in. Defaults to false
40 | final bool autoStart;
41 |
42 | FadeInController({this.autoStart = false});
43 |
44 | void dispose() => _streamController.close();
45 |
46 | /// Fades-in child
47 | void fadeIn() => run(FadeInAction.fadeIn);
48 |
49 | /// Fades-out child
50 | void fadeOut() => run(FadeInAction.fadeOut);
51 |
52 | /// Dispatches a [FadeInAction]
53 | void run(FadeInAction action) => _streamController.add(action);
54 |
55 | /// Stream of [FadeInAction]s dispatched by this controller
56 | Stream get stream => _streamController.stream;
57 | }
58 |
59 | class _FadeInState extends State with TickerProviderStateMixin {
60 | late AnimationController _controller;
61 | StreamSubscription? _listener;
62 |
63 | @override
64 | void initState() {
65 | super.initState();
66 |
67 | _controller = AnimationController(
68 | vsync: this,
69 | duration: widget.duration,
70 | );
71 |
72 | _setupCurve();
73 |
74 | if (widget.controller?.autoStart != false) {
75 | fadeIn();
76 | }
77 |
78 | _listen();
79 | }
80 |
81 | void _setupCurve() {
82 | final curve = CurvedAnimation(parent: _controller, curve: widget.curve);
83 |
84 | Tween(
85 | begin: 0.0,
86 | end: 1.0,
87 | ).animate(curve);
88 | }
89 |
90 | void _listen() {
91 | if (_listener != null) {
92 | _listener!.cancel();
93 | _listener = null;
94 | }
95 |
96 | if (widget.controller != null) {
97 | _listener = widget.controller!.stream.listen(_onAction);
98 | }
99 | }
100 |
101 | void _onAction(FadeInAction action) {
102 | switch (action) {
103 | case FadeInAction.fadeIn:
104 | fadeIn();
105 | break;
106 | case FadeInAction.fadeOut:
107 | fadeOut();
108 | break;
109 | }
110 | }
111 |
112 | @override
113 | void didUpdateWidget(FadeIn oldWidget) {
114 | if (oldWidget.controller != widget.controller) {
115 | _listen();
116 | }
117 |
118 | if (oldWidget.duration != widget.duration) {
119 | _controller.duration = widget.duration;
120 | }
121 |
122 | if (oldWidget.curve != widget.curve) {
123 | _setupCurve();
124 | }
125 |
126 | super.didUpdateWidget(oldWidget);
127 | }
128 |
129 | @override
130 | void dispose() {
131 | _controller.dispose();
132 | _listener?.cancel();
133 | super.dispose();
134 | }
135 |
136 | @override
137 | Widget build(BuildContext context) {
138 | return FadeTransition(
139 | opacity: _controller,
140 | child: widget.child,
141 | );
142 | }
143 |
144 | /// Fades-in child
145 | void fadeIn() => _controller.forward();
146 |
147 | /// Fades-out child
148 | void fadeOut() => _controller.reverse();
149 | }
150 |
--------------------------------------------------------------------------------
/lib/widgets/locationError.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 |
4 | import '../provider/weatherProvider.dart';
5 |
6 | class LocationError extends StatefulWidget {
7 | @override
8 | _LocationErrorState createState() => _LocationErrorState();
9 | }
10 |
11 | class _LocationErrorState extends State {
12 | @override
13 | Widget build(BuildContext context) {
14 | return Center(
15 | child: Column(
16 | mainAxisAlignment: MainAxisAlignment.center,
17 | children: [
18 | Icon(
19 | Icons.location_off,
20 | color: Colors.black,
21 | size: 75,
22 | ),
23 | SizedBox(height: 10),
24 | Text(
25 | 'Your Location is Disabled',
26 | style: TextStyle(
27 | color: Colors.black,
28 | fontSize: 25,
29 | fontWeight: FontWeight.w500,
30 | ),
31 | ),
32 | Padding(
33 | padding: const EdgeInsets.symmetric(horizontal: 75, vertical: 10),
34 | child: Text(
35 | "Please turn on your location service and refresh the app",
36 | textAlign: TextAlign.center,
37 | style: TextStyle(
38 | color: Colors.black,
39 | fontSize: 15,
40 | fontWeight: FontWeight.w400,
41 | ),
42 | ),
43 | ),
44 | ElevatedButton(
45 | style: ElevatedButton.styleFrom(
46 | backgroundColor: Theme.of(context).primaryColor,
47 | textStyle: TextStyle(color: Colors.white),
48 | padding: EdgeInsets.symmetric(horizontal: 50),
49 | ),
50 | child: Text('Enable Location'),
51 | onPressed: () async {
52 | await Provider.of(context, listen: false)
53 | .getWeatherData(context);
54 | },
55 | ),
56 | ],
57 | ),
58 | );
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/widgets/mainWeatherDetail.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs, sort_constructors_first
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_weather/helper/extensions.dart';
4 | import 'package:flutter_weather/theme/textStyle.dart';
5 | import 'package:flutter_weather/widgets/customShimmer.dart';
6 | import 'package:phosphor_flutter/phosphor_flutter.dart';
7 | import 'package:provider/provider.dart';
8 |
9 | import 'package:flutter_weather/provider/weatherProvider.dart';
10 | import 'package:flutter_weather/theme/colors.dart';
11 |
12 | import '../helper/utils.dart';
13 |
14 | class MainWeatherDetail extends StatelessWidget {
15 | @override
16 | Widget build(BuildContext context) {
17 | return Consumer(builder: (context, weatherProv, _) {
18 | if (weatherProv.isLoading) {
19 | return CustomShimmer(
20 | height: 132.0,
21 | borderRadius: BorderRadius.circular(16.0),
22 | );
23 | }
24 | return Container(
25 | padding: const EdgeInsets.symmetric(vertical: 8.0),
26 | decoration: BoxDecoration(
27 | color: backgroundWhite,
28 | borderRadius: BorderRadius.circular(16.0),
29 | ),
30 | child: Column(
31 | mainAxisSize: MainAxisSize.min,
32 | children: [
33 | Padding(
34 | padding: const EdgeInsets.symmetric(horizontal: 12.0),
35 | child: IntrinsicHeight(
36 | child: Row(
37 | children: [
38 | DetailInfoTile(
39 | icon: PhosphorIcon(
40 | PhosphorIconsRegular.thermometerSimple,
41 | color: Colors.white,
42 | ),
43 | title: 'Feels Like',
44 | data: weatherProv.isCelsius
45 | ? '${weatherProv.weather.feelsLike.toStringAsFixed(1)}°'
46 | : '${weatherProv.weather.feelsLike.toFahrenheit().toStringAsFixed(1)}°'),
47 | VerticalDivider(
48 | thickness: 1.0,
49 | indent: 4.0,
50 | endIndent: 4.0,
51 | color: backgroundBlue,
52 | ),
53 | DetailInfoTile(
54 | icon: PhosphorIcon(
55 | PhosphorIconsRegular.drop,
56 | color: Colors.white,
57 | ),
58 | title: 'Precipitation',
59 | data:
60 | '${weatherProv.additionalWeatherData.precipitation}%',
61 | ),
62 | VerticalDivider(
63 | thickness: 1.0,
64 | indent: 4.0,
65 | endIndent: 4.0,
66 | color: backgroundBlue,
67 | ),
68 | DetailInfoTile(
69 | icon: PhosphorIcon(
70 | PhosphorIconsRegular.sun,
71 | color: Colors.white,
72 | ),
73 | title: 'UV Index',
74 | data: uviValueToString(
75 | weatherProv.additionalWeatherData.uvi,
76 | ),
77 | ),
78 | ],
79 | ),
80 | ),
81 | ),
82 | Divider(
83 | thickness: 1.0,
84 | color: backgroundBlue,
85 | ),
86 | Padding(
87 | padding: const EdgeInsets.symmetric(horizontal: 12.0),
88 | child: IntrinsicHeight(
89 | child: Row(
90 | children: [
91 | DetailInfoTile(
92 | icon: PhosphorIcon(
93 | PhosphorIconsRegular.wind,
94 | color: Colors.white,
95 | ),
96 | title: 'Wind',
97 | data: '${weatherProv.weather.windSpeed} m/s',
98 | ),
99 | VerticalDivider(
100 | thickness: 1.0,
101 | indent: 4.0,
102 | endIndent: 4.0,
103 | color: backgroundBlue,
104 | ),
105 | DetailInfoTile(
106 | icon: PhosphorIcon(
107 | PhosphorIconsRegular.dropHalfBottom,
108 | color: Colors.white,
109 | ),
110 | title: 'Humidity',
111 | data: '${weatherProv.weather.humidity}%',
112 | ),
113 | VerticalDivider(
114 | thickness: 1.0,
115 | indent: 4.0,
116 | endIndent: 4.0,
117 | color: backgroundBlue,
118 | ),
119 | DetailInfoTile(
120 | icon: PhosphorIcon(
121 | PhosphorIconsRegular.cloud,
122 | color: Colors.white,
123 | ),
124 | title: 'Cloudiness',
125 | data: '${weatherProv.additionalWeatherData.clouds}%',
126 | ),
127 | ],
128 | ),
129 | ),
130 | ),
131 | ],
132 | ),
133 | );
134 | });
135 | }
136 | }
137 |
138 | class DetailInfoTile extends StatelessWidget {
139 | final String title;
140 | final String data;
141 | final Widget icon;
142 | const DetailInfoTile({
143 | Key? key,
144 | required this.title,
145 | required this.data,
146 | required this.icon,
147 | }) : super(key: key);
148 |
149 | @override
150 | Widget build(BuildContext context) {
151 | return Flexible(
152 | child: Row(
153 | mainAxisAlignment: MainAxisAlignment.center,
154 | children: [
155 | CircleAvatar(backgroundColor: primaryBlue, child: icon),
156 | const SizedBox(width: 8.0),
157 | Expanded(
158 | child: Column(
159 | crossAxisAlignment: CrossAxisAlignment.start,
160 | mainAxisAlignment: MainAxisAlignment.center,
161 | children: [
162 | FittedBox(child: Text(title, style: lightText)),
163 | FittedBox(
164 | child: ConstrainedBox(
165 | constraints: const BoxConstraints(minWidth: 1.0),
166 | child: Text(
167 | data,
168 | style: mediumText,
169 | maxLines: 1,
170 | ),
171 | ),
172 | ),
173 | ],
174 | ),
175 | )
176 | ],
177 | ),
178 | );
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/lib/widgets/mainWeatherInfo.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_weather/helper/extensions.dart';
3 | import 'package:flutter_weather/helper/utils.dart';
4 | import 'package:flutter_weather/provider/weatherProvider.dart';
5 | import 'package:flutter_weather/theme/textStyle.dart';
6 | import 'package:provider/provider.dart';
7 |
8 | import 'customShimmer.dart';
9 |
10 | class MainWeatherInfo extends StatelessWidget {
11 | @override
12 | Widget build(BuildContext context) {
13 | return Consumer(builder: (context, weatherProv, _) {
14 | if (weatherProv.isLoading) {
15 | return Row(
16 | mainAxisAlignment: MainAxisAlignment.spaceEvenly,
17 | children: [
18 | Expanded(
19 | child: CustomShimmer(
20 | height: 148.0,
21 | width: 148.0,
22 | ),
23 | ),
24 | const SizedBox(width: 16.0),
25 | CustomShimmer(
26 | height: 148.0,
27 | width: 148.0,
28 | ),
29 | ],
30 | );
31 | }
32 | return Padding(
33 | padding: const EdgeInsets.symmetric(horizontal: 16.0),
34 | child: Row(
35 | crossAxisAlignment: CrossAxisAlignment.center,
36 | children: [
37 | Expanded(
38 | child: Column(
39 | crossAxisAlignment: CrossAxisAlignment.start,
40 | children: [
41 | SizedBox(
42 | height: 100.0,
43 | child: Row(
44 | crossAxisAlignment: CrossAxisAlignment.start,
45 | children: [
46 | FittedBox(
47 | child: Text(
48 | weatherProv.isCelsius
49 | ? weatherProv.weather.temp.toStringAsFixed(1)
50 | : weatherProv.weather.temp
51 | .toFahrenheit()
52 | .toStringAsFixed(1),
53 | style: boldText.copyWith(fontSize: 86),
54 | ),
55 | ),
56 | Padding(
57 | padding: const EdgeInsets.only(top: 8.0),
58 | child: Text(
59 | weatherProv.measurementUnit,
60 | style: mediumText.copyWith(fontSize: 26),
61 | ),
62 | ),
63 | ],
64 | ),
65 | ),
66 | Text(
67 | weatherProv.weather.description.toTitleCase(),
68 | style: lightText.copyWith(fontSize: 16),
69 | )
70 | ],
71 | ),
72 | ),
73 | SizedBox(
74 | height: 148.0,
75 | width: 148.0,
76 | child: Image.asset(
77 | getWeatherImage(weatherProv.weather.weatherCategory),
78 | fit: BoxFit.cover,
79 | ),
80 | ),
81 | ],
82 | ),
83 | );
84 | });
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/lib/widgets/requestError.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_weather/provider/weatherProvider.dart';
3 | import 'package:provider/provider.dart';
4 |
5 | class RequestError extends StatelessWidget {
6 | @override
7 | Widget build(BuildContext context) {
8 | return Padding(
9 | padding: const EdgeInsets.symmetric(vertical: 150),
10 | child: Column(
11 | mainAxisAlignment: MainAxisAlignment.center,
12 | children: [
13 | Icon(
14 | Icons.wrong_location_outlined,
15 | color: Colors.blue,
16 | size: 100,
17 | ),
18 | SizedBox(height: 10),
19 | Text(
20 | 'No Search Result',
21 | style: TextStyle(
22 | color: Colors.blue,
23 | fontSize: 30,
24 | fontWeight: FontWeight.w700,
25 | ),
26 | ),
27 | Padding(
28 | padding: const EdgeInsets.symmetric(horizontal: 75, vertical: 10),
29 | child: Text(
30 | "Please make sure that you entered the correct location or check your device internet connection",
31 | textAlign: TextAlign.center,
32 | style: TextStyle(
33 | color: Colors.grey[700],
34 | fontSize: 15,
35 | fontWeight: FontWeight.w400,
36 | ),
37 | ),
38 | ),
39 | ElevatedButton(
40 | style: ElevatedButton.styleFrom(
41 | shape: RoundedRectangleBorder(
42 | borderRadius: BorderRadius.circular(25.0),
43 | ),
44 | ),
45 | child: Text('Return Home'),
46 | onPressed: () =>
47 | Provider.of(context, listen: false)
48 | .getWeatherData(context, notify: true),
49 | ),
50 | ],
51 | ),
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/widgets/sevenDayForecast.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_weather/helper/extensions.dart';
3 | import 'package:flutter_weather/models/dailyWeather.dart';
4 | import 'package:flutter_weather/provider/weatherProvider.dart';
5 | import 'package:flutter_weather/screens/sevenDayForecastDetailScreen.dart';
6 | import 'package:flutter_weather/theme/colors.dart';
7 | import 'package:flutter_weather/theme/textStyle.dart';
8 | import 'package:flutter_weather/widgets/customShimmer.dart';
9 | import 'package:intl/intl.dart';
10 | import 'package:phosphor_flutter/phosphor_flutter.dart';
11 | import 'package:provider/provider.dart';
12 |
13 | import '../helper/utils.dart';
14 |
15 | class SevenDayForecast extends StatelessWidget {
16 | @override
17 | Widget build(BuildContext context) {
18 | return Column(
19 | crossAxisAlignment: CrossAxisAlignment.start,
20 | children: [
21 | Padding(
22 | padding: const EdgeInsets.symmetric(horizontal: 8.0),
23 | child: Row(
24 | children: [
25 | PhosphorIcon(PhosphorIconsRegular.calendar),
26 | const SizedBox(width: 4.0),
27 | Text(
28 | '7-Day Forecast',
29 | style: TextStyle(
30 | fontSize: 17,
31 | fontWeight: FontWeight.bold,
32 | ),
33 | ),
34 | Spacer(),
35 | Consumer(
36 | builder: (context, weatherProv, _) {
37 | return TextButton(
38 | style: TextButton.styleFrom(
39 | visualDensity: VisualDensity.compact,
40 | padding: EdgeInsets.zero,
41 | textStyle: mediumText.copyWith(fontSize: 14.0),
42 | foregroundColor: primaryBlue,
43 | ),
44 | child: Text('more details ▶'),
45 | onPressed: weatherProv.isLoading
46 | ? null
47 | : () {
48 | Navigator.of(context)
49 | .pushNamed(SevenDayForecastDetail.routeName);
50 | },
51 | );
52 | },
53 | )
54 | ],
55 | ),
56 | ),
57 | const SizedBox(height: 8.0),
58 | Container(
59 | child: Consumer(
60 | builder: (context, weatherProv, _) {
61 | if (weatherProv.isLoading) {
62 | return ListView.builder(
63 | shrinkWrap: true,
64 | padding: EdgeInsets.zero,
65 | itemCount: 7,
66 | itemBuilder: (context, index) => CustomShimmer(
67 | height: 82.0,
68 | borderRadius: BorderRadius.circular(12.0),
69 | ),
70 | );
71 | }
72 | return ListView.builder(
73 | shrinkWrap: true,
74 | padding: EdgeInsets.zero,
75 | physics: const NeverScrollableScrollPhysics(),
76 | itemCount: weatherProv.dailyWeather.length,
77 | itemBuilder: (context, index) {
78 | final DailyWeather weather = weatherProv.dailyWeather[index];
79 | return Material(
80 | borderRadius: BorderRadius.circular(12.0),
81 | color: index.isEven ? backgroundWhite : Colors.white,
82 | child: InkWell(
83 | borderRadius: BorderRadius.circular(12.0),
84 | onTap: () {
85 | Navigator.of(context).pushNamed(
86 | SevenDayForecastDetail.routeName,
87 | arguments: index,
88 | );
89 | },
90 | child: Padding(
91 | padding: const EdgeInsets.all(12.0),
92 | child: Row(
93 | mainAxisAlignment: MainAxisAlignment.spaceBetween,
94 | children: [
95 | SizedBox(
96 | width: MediaQuery.sizeOf(context).width / 4,
97 | child: FittedBox(
98 | alignment: Alignment.centerLeft,
99 | fit: BoxFit.scaleDown,
100 | child: Text(
101 | index == 0
102 | ? 'Today'
103 | : DateFormat('EEEE').format(weather.date),
104 | style: semiboldText,
105 | maxLines: 1,
106 | ),
107 | ),
108 | ),
109 | Column(
110 | mainAxisAlignment: MainAxisAlignment.center,
111 | children: [
112 | SizedBox(
113 | height: 36.0,
114 | width: 36.0,
115 | child: Image.asset(
116 | getWeatherImage(weather.weatherCategory),
117 | fit: BoxFit.cover,
118 | ),
119 | ),
120 | const SizedBox(height: 4.0),
121 | Text(
122 | weather.weatherCategory,
123 | style: lightText,
124 | ),
125 | ],
126 | ),
127 | SizedBox(
128 | width: MediaQuery.sizeOf(context).width / 5,
129 | child: FittedBox(
130 | alignment: Alignment.centerLeft,
131 | fit: BoxFit.scaleDown,
132 | child: Text(
133 | weatherProv.isCelsius
134 | ? '${weather.tempMax.toStringAsFixed(0)}°/${weather.tempMin.toStringAsFixed(0)}°'
135 | : '${weather.tempMax.toFahrenheit().toStringAsFixed(0)}°/${weather.tempMin.toFahrenheit().toStringAsFixed(0)}°',
136 | style: semiboldText,
137 | ),
138 | ),
139 | ),
140 | ],
141 | ),
142 | ),
143 | ),
144 | );
145 | },
146 | );
147 | },
148 | ),
149 | ),
150 | ],
151 | );
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/lib/widgets/twentyFourHourForecast.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_weather/helper/extensions.dart';
3 | import 'package:flutter_weather/models/hourlyWeather.dart';
4 | import 'package:flutter_weather/provider/weatherProvider.dart';
5 | import 'package:flutter_weather/theme/colors.dart';
6 | import 'package:flutter_weather/theme/textStyle.dart';
7 | import 'package:flutter_weather/widgets/customShimmer.dart';
8 | import 'package:intl/intl.dart';
9 | import 'package:phosphor_flutter/phosphor_flutter.dart';
10 | import 'package:provider/provider.dart';
11 |
12 | import '../helper/utils.dart';
13 |
14 | class TwentyFourHourForecast extends StatelessWidget {
15 | @override
16 | Widget build(BuildContext context) {
17 | return Container(
18 | decoration: BoxDecoration(
19 | color: backgroundWhite, borderRadius: BorderRadius.circular(16.0)),
20 | child: Column(
21 | crossAxisAlignment: CrossAxisAlignment.start,
22 | children: [
23 | Padding(
24 | padding:
25 | const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
26 | child: Row(
27 | children: [
28 | PhosphorIcon(PhosphorIconsRegular.clock),
29 | const SizedBox(width: 4.0),
30 | Text(
31 | '24-Hour Forecast',
32 | style: semiboldText.copyWith(fontSize: 16),
33 | ),
34 | ],
35 | ),
36 | ),
37 | Consumer(
38 | builder: (context, weatherProv, _) {
39 | if (weatherProv.isLoading) {
40 | return SizedBox(
41 | height: 128.0,
42 | child: ListView.separated(
43 | scrollDirection: Axis.horizontal,
44 | physics: NeverScrollableScrollPhysics(),
45 | padding: const EdgeInsets.symmetric(horizontal: 16.0),
46 | itemCount: 10,
47 | separatorBuilder: (context, index) =>
48 | const SizedBox(width: 12.0),
49 | itemBuilder: (context, index) => CustomShimmer(
50 | height: 128.0,
51 | width: 64.0,
52 | ),
53 | ),
54 | );
55 | }
56 | return SizedBox(
57 | height: 128.0,
58 | child: ListView.builder(
59 | physics: BouncingScrollPhysics(),
60 | padding: const EdgeInsets.symmetric(horizontal: 12.0),
61 | scrollDirection: Axis.horizontal,
62 | itemCount: weatherProv.hourlyWeather.length,
63 | itemBuilder: (context, index) => HourlyWeatherWidget(
64 | index: index,
65 | data: weatherProv.hourlyWeather[index],
66 | ),
67 | ),
68 | );
69 | },
70 | ),
71 | const SizedBox(height: 8.0),
72 | ],
73 | ),
74 | );
75 | }
76 | }
77 |
78 | class HourlyWeatherWidget extends StatelessWidget {
79 | final int index;
80 | final HourlyWeather data;
81 | const HourlyWeatherWidget({
82 | Key? key,
83 | required this.index,
84 | required this.data,
85 | }) : super(key: key);
86 |
87 | @override
88 | Widget build(BuildContext context) {
89 | return Container(
90 | width: 124.0,
91 | child: Column(
92 | children: [
93 | Consumer(builder: (context, weatherProv, _) {
94 | return Text(
95 | weatherProv.isCelsius
96 | ? '${data.temp.toStringAsFixed(1)}°'
97 | : '${data.temp.toFahrenheit().toStringAsFixed(1)}°',
98 | style: semiboldText,
99 | );
100 | }),
101 | Stack(
102 | children: [
103 | Divider(
104 | thickness: 2.0,
105 | color: primaryBlue,
106 | ),
107 | if (index == 0)
108 | Positioned(
109 | top: 2.0,
110 | left: 0,
111 | right: 0,
112 | child: Container(
113 | width: 10.0,
114 | height: 10.0,
115 | decoration: BoxDecoration(
116 | color: Colors.yellow,
117 | shape: BoxShape.circle,
118 | ),
119 | ),
120 | )
121 | ],
122 | ),
123 | SizedBox(
124 | height: 42.0,
125 | width: 42.0,
126 | child: Image.asset(
127 | getWeatherImage(data.weatherCategory),
128 | fit: BoxFit.cover,
129 | ),
130 | ),
131 | FittedBox(
132 | child: Text(
133 | data.condition?.toTitleCase() ?? '',
134 | style: regularText.copyWith(fontSize: 12.0),
135 | ),
136 | ),
137 | const SizedBox(height: 2.0),
138 | Text(
139 | index == 0 ? 'Now' : DateFormat('hh:mm a').format(data.date),
140 | style: regularText,
141 | )
142 | ],
143 | ),
144 | );
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.10)
3 | project(runner LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "flutter_weather")
8 | # The unique GTK application identifier for this application. See:
9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 | set(APPLICATION_ID "com.example.flutter_weather")
11 |
12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13 | # versions of CMake.
14 | cmake_policy(SET CMP0063 NEW)
15 |
16 | # Load bundled libraries from the lib/ directory relative to the binary.
17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18 |
19 | # Root filesystem for cross-building.
20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27 | endif()
28 |
29 | # Define build configuration options.
30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31 | set(CMAKE_BUILD_TYPE "Debug" CACHE
32 | STRING "Flutter build mode" FORCE)
33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34 | "Debug" "Profile" "Release")
35 | endif()
36 |
37 | # Compilation settings that should be applied to most targets.
38 | #
39 | # Be cautious about adding new options here, as plugins use this function by
40 | # default. In most cases, you should add new options to specific targets instead
41 | # of modifying this function.
42 | function(APPLY_STANDARD_SETTINGS TARGET)
43 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
47 | endfunction()
48 |
49 | # Flutter library and tool build rules.
50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51 | add_subdirectory(${FLUTTER_MANAGED_DIR})
52 |
53 | # System-level dependencies.
54 | find_package(PkgConfig REQUIRED)
55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56 |
57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
58 |
59 | # Define the application target. To change its name, change BINARY_NAME above,
60 | # not the value here, or `flutter run` will no longer work.
61 | #
62 | # Any new source files that you add to the application should be added here.
63 | add_executable(${BINARY_NAME}
64 | "main.cc"
65 | "my_application.cc"
66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
67 | )
68 |
69 | # Apply the standard set of build settings. This can be removed for applications
70 | # that need different build settings.
71 | apply_standard_settings(${BINARY_NAME})
72 |
73 | # Add dependency libraries. Add any application-specific dependencies here.
74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
76 |
77 | # Run the Flutter tool portions of the build. This must not be removed.
78 | add_dependencies(${BINARY_NAME} flutter_assemble)
79 |
80 | # Only the install-generated bundle's copy of the executable will launch
81 | # correctly, since the resources must in the right relative locations. To avoid
82 | # people trying to run the unbundled copy, put it in a subdirectory instead of
83 | # the default top-level location.
84 | set_target_properties(${BINARY_NAME}
85 | PROPERTIES
86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
87 | )
88 |
89 | # Generated plugin build rules, which manage building the plugins and adding
90 | # them to the application.
91 | include(flutter/generated_plugins.cmake)
92 |
93 |
94 | # === Installation ===
95 | # By default, "installing" just makes a relocatable bundle in the build
96 | # directory.
97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
100 | endif()
101 |
102 | # Start with a clean build bundle directory every time.
103 | install(CODE "
104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
105 | " COMPONENT Runtime)
106 |
107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
109 |
110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
111 | COMPONENT Runtime)
112 |
113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
114 | COMPONENT Runtime)
115 |
116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
117 | COMPONENT Runtime)
118 |
119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
120 | install(FILES "${bundled_library}"
121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
122 | COMPONENT Runtime)
123 | endforeach(bundled_library)
124 |
125 | # Fully re-copy the assets directory on each build to avoid having stale files
126 | # from a previous install.
127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
128 | install(CODE "
129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
130 | " COMPONENT Runtime)
131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
133 |
134 | # Install the AOT library on non-Debug builds only.
135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
137 | COMPONENT Runtime)
138 | endif()
139 |
--------------------------------------------------------------------------------
/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 |
10 | void fl_register_plugins(FlPluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen* screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "flutter_weather");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | } else {
47 | gtk_window_set_title(window, "flutter_weather");
48 | }
49 |
50 | gtk_window_set_default_size(window, 1280, 720);
51 | gtk_widget_show(GTK_WIDGET(window));
52 |
53 | g_autoptr(FlDartProject) project = fl_dart_project_new();
54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
55 |
56 | FlView* view = fl_view_new(project);
57 | gtk_widget_show(GTK_WIDGET(view));
58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
59 |
60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
61 |
62 | gtk_widget_grab_focus(GTK_WIDGET(view));
63 | }
64 |
65 | // Implements GApplication::local_command_line.
66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
67 | MyApplication* self = MY_APPLICATION(application);
68 | // Strip out the first argument as it is the binary name.
69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
70 |
71 | g_autoptr(GError) error = nullptr;
72 | if (!g_application_register(application, nullptr, &error)) {
73 | g_warning("Failed to register: %s", error->message);
74 | *exit_status = 1;
75 | return TRUE;
76 | }
77 |
78 | g_application_activate(application);
79 | *exit_status = 0;
80 |
81 | return TRUE;
82 | }
83 |
84 | // Implements GObject::dispose.
85 | static void my_application_dispose(GObject* object) {
86 | MyApplication* self = MY_APPLICATION(object);
87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
89 | }
90 |
91 | static void my_application_class_init(MyApplicationClass* klass) {
92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
95 | }
96 |
97 | static void my_application_init(MyApplication* self) {}
98 |
99 | MyApplication* my_application_new() {
100 | return MY_APPLICATION(g_object_new(my_application_get_type(),
101 | "application-id", APPLICATION_ID,
102 | "flags", G_APPLICATION_NON_UNIQUE,
103 | nullptr));
104 | }
105 |
--------------------------------------------------------------------------------
/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import geolocator_apple
9 | import path_provider_foundation
10 |
11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
12 | GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
13 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
14 | }
15 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = flutter_weather
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeather
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
9 | url: "https://pub.dev"
10 | source: hosted
11 | version: "2.11.0"
12 | boolean_selector:
13 | dependency: transitive
14 | description:
15 | name: boolean_selector
16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17 | url: "https://pub.dev"
18 | source: hosted
19 | version: "2.1.1"
20 | characters:
21 | dependency: transitive
22 | description:
23 | name: characters
24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
25 | url: "https://pub.dev"
26 | source: hosted
27 | version: "1.3.0"
28 | clock:
29 | dependency: transitive
30 | description:
31 | name: clock
32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
33 | url: "https://pub.dev"
34 | source: hosted
35 | version: "1.1.1"
36 | collection:
37 | dependency: transitive
38 | description:
39 | name: collection
40 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
41 | url: "https://pub.dev"
42 | source: hosted
43 | version: "1.17.1"
44 | country_picker:
45 | dependency: "direct main"
46 | description:
47 | name: country_picker
48 | sha256: e440350c2f6397955499d5a647cc90599ba3048651c6858370483f55c346b525
49 | url: "https://pub.dev"
50 | source: hosted
51 | version: "2.0.21"
52 | crypto:
53 | dependency: transitive
54 | description:
55 | name: crypto
56 | sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
57 | url: "https://pub.dev"
58 | source: hosted
59 | version: "3.0.3"
60 | cupertino_icons:
61 | dependency: "direct main"
62 | description:
63 | name: cupertino_icons
64 | sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
65 | url: "https://pub.dev"
66 | source: hosted
67 | version: "1.0.6"
68 | fake_async:
69 | dependency: transitive
70 | description:
71 | name: fake_async
72 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
73 | url: "https://pub.dev"
74 | source: hosted
75 | version: "1.3.1"
76 | ffi:
77 | dependency: transitive
78 | description:
79 | name: ffi
80 | sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
81 | url: "https://pub.dev"
82 | source: hosted
83 | version: "2.1.0"
84 | flutter:
85 | dependency: "direct main"
86 | description: flutter
87 | source: sdk
88 | version: "0.0.0"
89 | flutter_test:
90 | dependency: "direct dev"
91 | description: flutter
92 | source: sdk
93 | version: "0.0.0"
94 | flutter_web_plugins:
95 | dependency: transitive
96 | description: flutter
97 | source: sdk
98 | version: "0.0.0"
99 | geolocator:
100 | dependency: "direct main"
101 | description:
102 | name: geolocator
103 | sha256: "5c23f3613f50586c0bbb2b8f970240ae66b3bd992088cf60dd5ee2e6f7dde3a8"
104 | url: "https://pub.dev"
105 | source: hosted
106 | version: "9.0.2"
107 | geolocator_android:
108 | dependency: transitive
109 | description:
110 | name: geolocator_android
111 | sha256: "741579fa6c9e412984d2bdb2fbaa54e3c3f7587c60aeacfe6e058358a11f40f8"
112 | url: "https://pub.dev"
113 | source: hosted
114 | version: "4.4.0"
115 | geolocator_apple:
116 | dependency: transitive
117 | description:
118 | name: geolocator_apple
119 | sha256: ab90ae811c42ec2f6021e01eca71df00dee6ff1e69d2c2dafd4daeb0b793f73d
120 | url: "https://pub.dev"
121 | source: hosted
122 | version: "2.3.2"
123 | geolocator_platform_interface:
124 | dependency: transitive
125 | description:
126 | name: geolocator_platform_interface
127 | sha256: "6c8d494d6948757c56720b778af742f6973f31fca1f702a7539b8917e4a2468a"
128 | url: "https://pub.dev"
129 | source: hosted
130 | version: "4.2.0"
131 | geolocator_web:
132 | dependency: transitive
133 | description:
134 | name: geolocator_web
135 | sha256: "59083f7e0871b78299918d92bf930a14377f711d2d1156c558cd5ebae6c20d58"
136 | url: "https://pub.dev"
137 | source: hosted
138 | version: "2.2.0"
139 | geolocator_windows:
140 | dependency: transitive
141 | description:
142 | name: geolocator_windows
143 | sha256: "4f4218f122a6978d0ad655fa3541eea74c67417440b09f0657238810d5af6bdc"
144 | url: "https://pub.dev"
145 | source: hosted
146 | version: "0.1.3"
147 | google_fonts:
148 | dependency: "direct main"
149 | description:
150 | name: google_fonts
151 | sha256: f0b8d115a13ecf827013ec9fc883390ccc0e87a96ed5347a3114cac177ef18e8
152 | url: "https://pub.dev"
153 | source: hosted
154 | version: "6.1.0"
155 | http:
156 | dependency: "direct main"
157 | description:
158 | name: http
159 | sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
160 | url: "https://pub.dev"
161 | source: hosted
162 | version: "1.1.0"
163 | http_parser:
164 | dependency: transitive
165 | description:
166 | name: http_parser
167 | sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
168 | url: "https://pub.dev"
169 | source: hosted
170 | version: "4.0.2"
171 | intl:
172 | dependency: "direct main"
173 | description:
174 | name: intl
175 | sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
176 | url: "https://pub.dev"
177 | source: hosted
178 | version: "0.18.1"
179 | js:
180 | dependency: transitive
181 | description:
182 | name: js
183 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
184 | url: "https://pub.dev"
185 | source: hosted
186 | version: "0.6.7"
187 | latlong2:
188 | dependency: "direct main"
189 | description:
190 | name: latlong2
191 | sha256: "08ef7282ba9f76e8495e49e2dc4d653015ac929dce5f92b375a415d30b407ea0"
192 | url: "https://pub.dev"
193 | source: hosted
194 | version: "0.8.2"
195 | matcher:
196 | dependency: transitive
197 | description:
198 | name: matcher
199 | sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
200 | url: "https://pub.dev"
201 | source: hosted
202 | version: "0.12.15"
203 | material_color_utilities:
204 | dependency: transitive
205 | description:
206 | name: material_color_utilities
207 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
208 | url: "https://pub.dev"
209 | source: hosted
210 | version: "0.2.0"
211 | material_floating_search_bar_2:
212 | dependency: "direct main"
213 | description:
214 | name: material_floating_search_bar_2
215 | sha256: ab0c6d209d9491f98dd4c72f2641d0ba1dd35c87effca1f23d8679bece43add0
216 | url: "https://pub.dev"
217 | source: hosted
218 | version: "0.5.0"
219 | meta:
220 | dependency: transitive
221 | description:
222 | name: meta
223 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
224 | url: "https://pub.dev"
225 | source: hosted
226 | version: "1.9.1"
227 | nested:
228 | dependency: transitive
229 | description:
230 | name: nested
231 | sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
232 | url: "https://pub.dev"
233 | source: hosted
234 | version: "1.0.0"
235 | path:
236 | dependency: transitive
237 | description:
238 | name: path
239 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
240 | url: "https://pub.dev"
241 | source: hosted
242 | version: "1.8.3"
243 | path_provider:
244 | dependency: transitive
245 | description:
246 | name: path_provider
247 | sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
248 | url: "https://pub.dev"
249 | source: hosted
250 | version: "2.1.1"
251 | path_provider_android:
252 | dependency: transitive
253 | description:
254 | name: path_provider_android
255 | sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
256 | url: "https://pub.dev"
257 | source: hosted
258 | version: "2.2.1"
259 | path_provider_foundation:
260 | dependency: transitive
261 | description:
262 | name: path_provider_foundation
263 | sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
264 | url: "https://pub.dev"
265 | source: hosted
266 | version: "2.3.1"
267 | path_provider_linux:
268 | dependency: transitive
269 | description:
270 | name: path_provider_linux
271 | sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
272 | url: "https://pub.dev"
273 | source: hosted
274 | version: "2.2.1"
275 | path_provider_platform_interface:
276 | dependency: transitive
277 | description:
278 | name: path_provider_platform_interface
279 | sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
280 | url: "https://pub.dev"
281 | source: hosted
282 | version: "2.1.1"
283 | path_provider_windows:
284 | dependency: transitive
285 | description:
286 | name: path_provider_windows
287 | sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
288 | url: "https://pub.dev"
289 | source: hosted
290 | version: "2.2.1"
291 | phosphor_flutter:
292 | dependency: "direct main"
293 | description:
294 | name: phosphor_flutter
295 | sha256: "3b3e6e4cbda8208f8c1431b0999842f0b76db73853dd824fd4847a9f0166931a"
296 | url: "https://pub.dev"
297 | source: hosted
298 | version: "2.0.1"
299 | platform:
300 | dependency: transitive
301 | description:
302 | name: platform
303 | sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
304 | url: "https://pub.dev"
305 | source: hosted
306 | version: "3.1.3"
307 | plugin_platform_interface:
308 | dependency: transitive
309 | description:
310 | name: plugin_platform_interface
311 | sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
312 | url: "https://pub.dev"
313 | source: hosted
314 | version: "2.1.7"
315 | provider:
316 | dependency: "direct main"
317 | description:
318 | name: provider
319 | sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
320 | url: "https://pub.dev"
321 | source: hosted
322 | version: "6.1.1"
323 | shimmer:
324 | dependency: "direct main"
325 | description:
326 | name: shimmer
327 | sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9"
328 | url: "https://pub.dev"
329 | source: hosted
330 | version: "3.0.0"
331 | simple_animations:
332 | dependency: "direct main"
333 | description:
334 | name: simple_animations
335 | sha256: "1ea7b93fb98e2a611b6865d632de55607b766328d14700143353129ee0559d3a"
336 | url: "https://pub.dev"
337 | source: hosted
338 | version: "5.0.2"
339 | sky_engine:
340 | dependency: transitive
341 | description: flutter
342 | source: sdk
343 | version: "0.0.99"
344 | source_span:
345 | dependency: transitive
346 | description:
347 | name: source_span
348 | sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
349 | url: "https://pub.dev"
350 | source: hosted
351 | version: "1.9.1"
352 | sprintf:
353 | dependency: transitive
354 | description:
355 | name: sprintf
356 | sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
357 | url: "https://pub.dev"
358 | source: hosted
359 | version: "7.0.0"
360 | stack_trace:
361 | dependency: transitive
362 | description:
363 | name: stack_trace
364 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
365 | url: "https://pub.dev"
366 | source: hosted
367 | version: "1.11.0"
368 | stream_channel:
369 | dependency: transitive
370 | description:
371 | name: stream_channel
372 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
373 | url: "https://pub.dev"
374 | source: hosted
375 | version: "2.1.1"
376 | string_scanner:
377 | dependency: transitive
378 | description:
379 | name: string_scanner
380 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
381 | url: "https://pub.dev"
382 | source: hosted
383 | version: "1.2.0"
384 | supercharged:
385 | dependency: "direct main"
386 | description:
387 | name: supercharged
388 | sha256: ab49c848b33e28243f5ce82b976736de17d0852b71d0dfbde53fbb5e2ecca7cb
389 | url: "https://pub.dev"
390 | source: hosted
391 | version: "2.1.1"
392 | supercharged_dart:
393 | dependency: transitive
394 | description:
395 | name: supercharged_dart
396 | sha256: cb95edda32eacd27664089700a750120be41daa84aa6cd2aeded46227c16b867
397 | url: "https://pub.dev"
398 | source: hosted
399 | version: "2.1.1"
400 | term_glyph:
401 | dependency: transitive
402 | description:
403 | name: term_glyph
404 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
405 | url: "https://pub.dev"
406 | source: hosted
407 | version: "1.2.1"
408 | test_api:
409 | dependency: transitive
410 | description:
411 | name: test_api
412 | sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
413 | url: "https://pub.dev"
414 | source: hosted
415 | version: "0.5.1"
416 | typed_data:
417 | dependency: transitive
418 | description:
419 | name: typed_data
420 | sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
421 | url: "https://pub.dev"
422 | source: hosted
423 | version: "1.3.2"
424 | universal_io:
425 | dependency: transitive
426 | description:
427 | name: universal_io
428 | sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
429 | url: "https://pub.dev"
430 | source: hosted
431 | version: "2.2.2"
432 | uuid:
433 | dependency: transitive
434 | description:
435 | name: uuid
436 | sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f"
437 | url: "https://pub.dev"
438 | source: hosted
439 | version: "4.2.2"
440 | vector_math:
441 | dependency: transitive
442 | description:
443 | name: vector_math
444 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
445 | url: "https://pub.dev"
446 | source: hosted
447 | version: "2.1.4"
448 | win32:
449 | dependency: transitive
450 | description:
451 | name: win32
452 | sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3"
453 | url: "https://pub.dev"
454 | source: hosted
455 | version: "5.0.9"
456 | xdg_directories:
457 | dependency: transitive
458 | description:
459 | name: xdg_directories
460 | sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
461 | url: "https://pub.dev"
462 | source: hosted
463 | version: "1.0.3"
464 | sdks:
465 | dart: ">=3.0.0 <4.0.0"
466 | flutter: ">=3.7.0"
467 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_weather
2 | description: A new Flutter project.
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 | # The following defines the version and build number for your application.
9 | # A version number is three numbers separated by dots, like 1.2.43
10 | # followed by an optional build number separated by a +.
11 | # Both the version and the builder number may be overridden in flutter
12 | # build by specifying --build-name and --build-number, respectively.
13 | # In Android, build-name is used as versionName while build-number used as versionCode.
14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
16 | # Read more about iOS versioning at
17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18 | version: 1.0.0+1
19 |
20 | environment:
21 | sdk: ">=2.12.0 <3.0.0"
22 |
23 | dependencies:
24 | flutter:
25 | sdk: flutter
26 | country_picker: ^2.0.20
27 | cupertino_icons: ^1.0.0
28 | google_fonts: ^6.1.0
29 | geolocator: ^9.0.2
30 | http: ^1.1.0
31 | intl: ^0.18.0
32 | latlong2: ^0.8.1
33 | material_floating_search_bar_2: ^0.5.0
34 | phosphor_flutter: ^2.0.1
35 | provider: ^6.0.5
36 | shimmer: ^3.0.0
37 | simple_animations: ^5.0.0+3
38 | supercharged: ^2.1.1
39 |
40 |
41 | dev_dependencies:
42 | flutter_test:
43 | sdk: flutter
44 |
45 | # For information on the generic Dart part of this file, see the
46 | # following page: https://dart.dev/tools/pub/pubspec
47 | # The following section is specific to Flutter.
48 | flutter:
49 |
50 | # The following line ensures that the Material Icons font is
51 | # included with your application, so that you can use the icons in
52 | # the material Icons class.
53 | uses-material-design: true
54 | # To add assets to your application, add an assets section, like this:
55 | assets:
56 | - assets/images/
57 |
58 | # An image asset can refer to one or more resolution-specific "variants", see
59 | # https://flutter.dev/assets-and-images/#resolution-aware.
60 | # For details regarding adding assets from package dependencies, see
61 | # https://flutter.dev/assets-and-images/#from-packages
62 | # To add custom fonts to your application, add a fonts section here,
63 | # in this "flutter" section. Each entry in this list should have a
64 | # "family" key with the font family name, and a "fonts" key with a
65 | # list giving the asset and other descriptors for the font. For
66 | # example:
67 | # fonts:
68 | # - family: Schyler
69 | # fonts:
70 | # - asset: fonts/Schyler-Regular.ttf
71 | # - asset: fonts/Schyler-Italic.ttf
72 | # style: italic
73 | # - family: Trajan Pro
74 | # fonts:
75 | # - asset: fonts/TrajanPro.ttf
76 | # - asset: fonts/TrajanPro_Bold.ttf
77 | # weight: 700
78 | #
79 | # For details regarding fonts from package dependencies,
80 | # see https://flutter.dev/custom-fonts/#from-packages
81 |
--------------------------------------------------------------------------------
/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 in the flutter_test package. 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/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(MyApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/web/favicon.png
--------------------------------------------------------------------------------
/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | flutter_weather
33 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flutter_weather",
3 | "short_name": "flutter_weather",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | },
22 | {
23 | "src": "icons/Icon-maskable-192.png",
24 | "sizes": "192x192",
25 | "type": "image/png",
26 | "purpose": "maskable"
27 | },
28 | {
29 | "src": "icons/Icon-maskable-512.png",
30 | "sizes": "512x512",
31 | "type": "image/png",
32 | "purpose": "maskable"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.14)
3 | project(flutter_weather LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "flutter_weather")
8 |
9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10 | # versions of CMake.
11 | cmake_policy(SET CMP0063 NEW)
12 |
13 | # Define build configuration option.
14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15 | if(IS_MULTICONFIG)
16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17 | CACHE STRING "" FORCE)
18 | else()
19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20 | set(CMAKE_BUILD_TYPE "Debug" CACHE
21 | STRING "Flutter build mode" FORCE)
22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23 | "Debug" "Profile" "Release")
24 | endif()
25 | endif()
26 | # Define settings for the Profile build mode.
27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31 |
32 | # Use Unicode for all projects.
33 | add_definitions(-DUNICODE -D_UNICODE)
34 |
35 | # Compilation settings that should be applied to most targets.
36 | #
37 | # Be cautious about adding new options here, as plugins use this function by
38 | # default. In most cases, you should add new options to specific targets instead
39 | # of modifying this function.
40 | function(APPLY_STANDARD_SETTINGS TARGET)
41 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43 | target_compile_options(${TARGET} PRIVATE /EHsc)
44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
46 | endfunction()
47 |
48 | # Flutter library and tool build rules.
49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50 | add_subdirectory(${FLUTTER_MANAGED_DIR})
51 |
52 | # Application build; see runner/CMakeLists.txt.
53 | add_subdirectory("runner")
54 |
55 | # Generated plugin build rules, which manage building the plugins and adding
56 | # them to the application.
57 | include(flutter/generated_plugins.cmake)
58 |
59 |
60 | # === Installation ===
61 | # Support files are copied into place next to the executable, so that it can
62 | # run in place. This is done instead of making a separate bundle (as on Linux)
63 | # so that building and running from within Visual Studio will work.
64 | set(BUILD_BUNDLE_DIR "$")
65 | # Make the "install" step default, as it's required to run.
66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
69 | endif()
70 |
71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
73 |
74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
75 | COMPONENT Runtime)
76 |
77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
78 | COMPONENT Runtime)
79 |
80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
81 | COMPONENT Runtime)
82 |
83 | if(PLUGIN_BUNDLED_LIBRARIES)
84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
86 | COMPONENT Runtime)
87 | endif()
88 |
89 | # Fully re-copy the assets directory on each build to avoid having stale files
90 | # from a previous install.
91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
92 | install(CODE "
93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
94 | " COMPONENT Runtime)
95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
97 |
98 | # Install the AOT library on non-Debug builds only.
99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
100 | CONFIGURATIONS Profile;Release
101 | COMPONENT Runtime)
102 |
--------------------------------------------------------------------------------
/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.14)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12 |
13 | # === Flutter Library ===
14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
15 |
16 | # Published to parent scope for install step.
17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
21 |
22 | list(APPEND FLUTTER_LIBRARY_HEADERS
23 | "flutter_export.h"
24 | "flutter_windows.h"
25 | "flutter_messenger.h"
26 | "flutter_plugin_registrar.h"
27 | "flutter_texture_registrar.h"
28 | )
29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
30 | add_library(flutter INTERFACE)
31 | target_include_directories(flutter INTERFACE
32 | "${EPHEMERAL_DIR}"
33 | )
34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
35 | add_dependencies(flutter flutter_assemble)
36 |
37 | # === Wrapper ===
38 | list(APPEND CPP_WRAPPER_SOURCES_CORE
39 | "core_implementations.cc"
40 | "standard_codec.cc"
41 | )
42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
44 | "plugin_registrar.cc"
45 | )
46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
47 | list(APPEND CPP_WRAPPER_SOURCES_APP
48 | "flutter_engine.cc"
49 | "flutter_view_controller.cc"
50 | )
51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
52 |
53 | # Wrapper sources needed for a plugin.
54 | add_library(flutter_wrapper_plugin STATIC
55 | ${CPP_WRAPPER_SOURCES_CORE}
56 | ${CPP_WRAPPER_SOURCES_PLUGIN}
57 | )
58 | apply_standard_settings(flutter_wrapper_plugin)
59 | set_target_properties(flutter_wrapper_plugin PROPERTIES
60 | POSITION_INDEPENDENT_CODE ON)
61 | set_target_properties(flutter_wrapper_plugin PROPERTIES
62 | CXX_VISIBILITY_PRESET hidden)
63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
64 | target_include_directories(flutter_wrapper_plugin PUBLIC
65 | "${WRAPPER_ROOT}/include"
66 | )
67 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
68 |
69 | # Wrapper sources needed for the runner.
70 | add_library(flutter_wrapper_app STATIC
71 | ${CPP_WRAPPER_SOURCES_CORE}
72 | ${CPP_WRAPPER_SOURCES_APP}
73 | )
74 | apply_standard_settings(flutter_wrapper_app)
75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
76 | target_include_directories(flutter_wrapper_app PUBLIC
77 | "${WRAPPER_ROOT}/include"
78 | )
79 | add_dependencies(flutter_wrapper_app flutter_assemble)
80 |
81 | # === Flutter tool backend ===
82 | # _phony_ is a non-existent file to force this command to run every time,
83 | # since currently there's no way to get a full input/output list from the
84 | # flutter tool.
85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
87 | add_custom_command(
88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
90 | ${CPP_WRAPPER_SOURCES_APP}
91 | ${PHONY_OUTPUT}
92 | COMMAND ${CMAKE_COMMAND} -E env
93 | ${FLUTTER_TOOL_ENVIRONMENT}
94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
95 | windows-x64 $
96 | VERBATIM
97 | )
98 | add_custom_target(flutter_assemble DEPENDS
99 | "${FLUTTER_LIBRARY}"
100 | ${FLUTTER_LIBRARY_HEADERS}
101 | ${CPP_WRAPPER_SOURCES_CORE}
102 | ${CPP_WRAPPER_SOURCES_PLUGIN}
103 | ${CPP_WRAPPER_SOURCES_APP}
104 | )
105 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void RegisterPlugins(flutter::PluginRegistry* registry) {
12 | GeolocatorWindowsRegisterWithRegistrar(
13 | registry->GetRegistrarForPlugin("GeolocatorWindows"));
14 | }
15 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | geolocator_windows
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | # Define the application target. To change its name, change BINARY_NAME in the
5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6 | # work.
7 | #
8 | # Any new source files that you add to the application should be added here.
9 | add_executable(${BINARY_NAME} WIN32
10 | "flutter_window.cpp"
11 | "main.cpp"
12 | "utils.cpp"
13 | "win32_window.cpp"
14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15 | "Runner.rc"
16 | "runner.exe.manifest"
17 | )
18 |
19 | # Apply the standard set of build settings. This can be removed for applications
20 | # that need different build settings.
21 | apply_standard_settings(${BINARY_NAME})
22 |
23 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
37 |
38 | # Run the Flutter tool portions of the build. This must not be removed.
39 | add_dependencies(${BINARY_NAME} flutter_assemble)
40 |
--------------------------------------------------------------------------------
/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "flutter_weather" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "flutter_weather" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "flutter_weather.exe" "\0"
98 | VALUE "ProductName", "flutter_weather" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 | return true;
30 | }
31 |
32 | void FlutterWindow::OnDestroy() {
33 | if (flutter_controller_) {
34 | flutter_controller_ = nullptr;
35 | }
36 |
37 | Win32Window::OnDestroy();
38 | }
39 |
40 | LRESULT
41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
42 | WPARAM const wparam,
43 | LPARAM const lparam) noexcept {
44 | // Give Flutter, including plugins, an opportunity to handle window messages.
45 | if (flutter_controller_) {
46 | std::optional result =
47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
48 | lparam);
49 | if (result) {
50 | return *result;
51 | }
52 | }
53 |
54 | switch (message) {
55 | case WM_FONTCHANGE:
56 | flutter_controller_->engine()->ReloadSystemFonts();
57 | break;
58 | }
59 |
60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
61 | }
62 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(1280, 720);
30 | if (!window.CreateAndShow(L"flutter_weather", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArizArmeidi/FlutterWeather/1f61a2bda72f616e6999da6a4d56946096899654/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | std::string utf8_string;
52 | if (target_length == 0 || target_length > utf8_string.max_size()) {
53 | return utf8_string;
54 | }
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.cpp:
--------------------------------------------------------------------------------
1 | #include "win32_window.h"
2 |
3 | #include
4 |
5 | #include "resource.h"
6 |
7 | namespace {
8 |
9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
10 |
11 | // The number of Win32Window objects that currently exist.
12 | static int g_active_window_count = 0;
13 |
14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
15 |
16 | // Scale helper to convert logical scaler values to physical using passed in
17 | // scale factor
18 | int Scale(int source, double scale_factor) {
19 | return static_cast(source * scale_factor);
20 | }
21 |
22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
23 | // This API is only needed for PerMonitor V1 awareness mode.
24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) {
25 | HMODULE user32_module = LoadLibraryA("User32.dll");
26 | if (!user32_module) {
27 | return;
28 | }
29 | auto enable_non_client_dpi_scaling =
30 | reinterpret_cast(
31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
32 | if (enable_non_client_dpi_scaling != nullptr) {
33 | enable_non_client_dpi_scaling(hwnd);
34 | FreeLibrary(user32_module);
35 | }
36 | }
37 |
38 | } // namespace
39 |
40 | // Manages the Win32Window's window class registration.
41 | class WindowClassRegistrar {
42 | public:
43 | ~WindowClassRegistrar() = default;
44 |
45 | // Returns the singleton registar instance.
46 | static WindowClassRegistrar* GetInstance() {
47 | if (!instance_) {
48 | instance_ = new WindowClassRegistrar();
49 | }
50 | return instance_;
51 | }
52 |
53 | // Returns the name of the window class, registering the class if it hasn't
54 | // previously been registered.
55 | const wchar_t* GetWindowClass();
56 |
57 | // Unregisters the window class. Should only be called if there are no
58 | // instances of the window.
59 | void UnregisterWindowClass();
60 |
61 | private:
62 | WindowClassRegistrar() = default;
63 |
64 | static WindowClassRegistrar* instance_;
65 |
66 | bool class_registered_ = false;
67 | };
68 |
69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
70 |
71 | const wchar_t* WindowClassRegistrar::GetWindowClass() {
72 | if (!class_registered_) {
73 | WNDCLASS window_class{};
74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
75 | window_class.lpszClassName = kWindowClassName;
76 | window_class.style = CS_HREDRAW | CS_VREDRAW;
77 | window_class.cbClsExtra = 0;
78 | window_class.cbWndExtra = 0;
79 | window_class.hInstance = GetModuleHandle(nullptr);
80 | window_class.hIcon =
81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
82 | window_class.hbrBackground = 0;
83 | window_class.lpszMenuName = nullptr;
84 | window_class.lpfnWndProc = Win32Window::WndProc;
85 | RegisterClass(&window_class);
86 | class_registered_ = true;
87 | }
88 | return kWindowClassName;
89 | }
90 |
91 | void WindowClassRegistrar::UnregisterWindowClass() {
92 | UnregisterClass(kWindowClassName, nullptr);
93 | class_registered_ = false;
94 | }
95 |
96 | Win32Window::Win32Window() {
97 | ++g_active_window_count;
98 | }
99 |
100 | Win32Window::~Win32Window() {
101 | --g_active_window_count;
102 | Destroy();
103 | }
104 |
105 | bool Win32Window::CreateAndShow(const std::wstring& title,
106 | const Point& origin,
107 | const Size& size) {
108 | Destroy();
109 |
110 | const wchar_t* window_class =
111 | WindowClassRegistrar::GetInstance()->GetWindowClass();
112 |
113 | const POINT target_point = {static_cast(origin.x),
114 | static_cast(origin.y)};
115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
117 | double scale_factor = dpi / 96.0;
118 |
119 | HWND window = CreateWindow(
120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor),
123 | nullptr, nullptr, GetModuleHandle(nullptr), this);
124 |
125 | if (!window) {
126 | return false;
127 | }
128 |
129 | return OnCreate();
130 | }
131 |
132 | // static
133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window,
134 | UINT const message,
135 | WPARAM const wparam,
136 | LPARAM const lparam) noexcept {
137 | if (message == WM_NCCREATE) {
138 | auto window_struct = reinterpret_cast(lparam);
139 | SetWindowLongPtr(window, GWLP_USERDATA,
140 | reinterpret_cast(window_struct->lpCreateParams));
141 |
142 | auto that = static_cast(window_struct->lpCreateParams);
143 | EnableFullDpiSupportIfAvailable(window);
144 | that->window_handle_ = window;
145 | } else if (Win32Window* that = GetThisFromHandle(window)) {
146 | return that->MessageHandler(window, message, wparam, lparam);
147 | }
148 |
149 | return DefWindowProc(window, message, wparam, lparam);
150 | }
151 |
152 | LRESULT
153 | Win32Window::MessageHandler(HWND hwnd,
154 | UINT const message,
155 | WPARAM const wparam,
156 | LPARAM const lparam) noexcept {
157 | switch (message) {
158 | case WM_DESTROY:
159 | window_handle_ = nullptr;
160 | Destroy();
161 | if (quit_on_close_) {
162 | PostQuitMessage(0);
163 | }
164 | return 0;
165 |
166 | case WM_DPICHANGED: {
167 | auto newRectSize = reinterpret_cast(lparam);
168 | LONG newWidth = newRectSize->right - newRectSize->left;
169 | LONG newHeight = newRectSize->bottom - newRectSize->top;
170 |
171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
173 |
174 | return 0;
175 | }
176 | case WM_SIZE: {
177 | RECT rect = GetClientArea();
178 | if (child_content_ != nullptr) {
179 | // Size and position the child window.
180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
181 | rect.bottom - rect.top, TRUE);
182 | }
183 | return 0;
184 | }
185 |
186 | case WM_ACTIVATE:
187 | if (child_content_ != nullptr) {
188 | SetFocus(child_content_);
189 | }
190 | return 0;
191 | }
192 |
193 | return DefWindowProc(window_handle_, message, wparam, lparam);
194 | }
195 |
196 | void Win32Window::Destroy() {
197 | OnDestroy();
198 |
199 | if (window_handle_) {
200 | DestroyWindow(window_handle_);
201 | window_handle_ = nullptr;
202 | }
203 | if (g_active_window_count == 0) {
204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
205 | }
206 | }
207 |
208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
209 | return reinterpret_cast(
210 | GetWindowLongPtr(window, GWLP_USERDATA));
211 | }
212 |
213 | void Win32Window::SetChildContent(HWND content) {
214 | child_content_ = content;
215 | SetParent(content, window_handle_);
216 | RECT frame = GetClientArea();
217 |
218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
219 | frame.bottom - frame.top, true);
220 |
221 | SetFocus(child_content_);
222 | }
223 |
224 | RECT Win32Window::GetClientArea() {
225 | RECT frame;
226 | GetClientRect(window_handle_, &frame);
227 | return frame;
228 | }
229 |
230 | HWND Win32Window::GetHandle() {
231 | return window_handle_;
232 | }
233 |
234 | void Win32Window::SetQuitOnClose(bool quit_on_close) {
235 | quit_on_close_ = quit_on_close;
236 | }
237 |
238 | bool Win32Window::OnCreate() {
239 | // No-op; provided for subclasses.
240 | return true;
241 | }
242 |
243 | void Win32Window::OnDestroy() {
244 | // No-op; provided for subclasses.
245 | }
246 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------