├── .github └── FUNDING.yml ├── .gitignore ├── .metadata ├── README.md ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── flutter_weather_app_sample │ │ │ │ └── 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 ├── coverage └── lcov.info ├── 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 ├── data │ ├── constants.dart │ ├── datasources │ │ └── remote_data_source.dart │ ├── exception.dart │ ├── failure.dart │ ├── models │ │ └── weather_model.dart │ └── repositories │ │ └── weather_repository_impl.dart ├── domain │ ├── entities │ │ └── weather.dart │ ├── repositories │ │ └── weather_repository.dart │ └── usecases │ │ └── get_current_weather.dart ├── injection.dart ├── main.dart └── presentation │ ├── bloc │ ├── weather_bloc.dart │ ├── weather_event.dart │ └── weather_state.dart │ └── pages │ └── weather_page.dart ├── pubspec.lock ├── pubspec.yaml ├── test ├── data │ ├── datasources │ │ └── remote_data_source_test.dart │ ├── models │ │ └── weather_model_test.dart │ └── repositories │ │ └── weather_repository_impl_test.dart ├── domain │ └── usecases │ │ └── get_current_weather_test.dart ├── helpers │ ├── dummy_data │ │ └── dummy_weather_response.json │ ├── json_reader.dart │ ├── test_helper.dart │ └── test_helper.mocks.dart └── presentation │ ├── bloc │ ├── weather_bloc_test.dart │ └── weather_bloc_test.mocks.dart │ └── pages │ ├── weather_page_test.dart │ └── weather_page_test.mocks.dart └── web ├── favicon.png ├── icons ├── Icon-192.png └── Icon-512.png ├── index.html └── manifest.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: codestronaut 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f4abaa0735eba4dfd8f33f73363911d63931fe03 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_weather_app_sample 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 30 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | defaultConfig { 36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 37 | applicationId "com.example.flutter_weather_app_sample" 38 | minSdkVersion 16 39 | targetSdkVersion 30 40 | versionCode flutterVersionCode.toInteger() 41 | versionName flutterVersionName 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 59 | } 60 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutter_weather_app_sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_weather_app_sample 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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /coverage/lcov.info: -------------------------------------------------------------------------------- 1 | SF:lib/data/constants.dart 2 | DA:4,1 3 | DA:5,1 4 | DA:6,1 5 | DA:7,1 6 | LF:4 7 | LH:4 8 | end_of_record 9 | SF:lib/data/datasources/remote_data_source.dart 10 | DA:14,1 11 | DA:17,1 12 | DA:19,5 13 | DA:21,2 14 | DA:22,3 15 | DA:24,1 16 | LF:6 17 | LH:6 18 | end_of_record 19 | SF:lib/data/models/weather_model.dart 20 | DA:5,4 21 | DA:23,4 22 | DA:24,2 23 | DA:25,6 24 | DA:26,6 25 | DA:27,6 26 | DA:28,4 27 | DA:29,4 28 | DA:30,4 29 | DA:33,2 30 | DA:34,1 31 | DA:35,1 32 | DA:36,1 33 | DA:37,1 34 | DA:38,1 35 | DA:41,1 36 | DA:42,1 37 | DA:43,1 38 | DA:44,1 39 | DA:46,1 40 | DA:49,4 41 | DA:50,2 42 | DA:51,2 43 | DA:52,2 44 | DA:53,2 45 | DA:54,2 46 | DA:55,2 47 | DA:56,2 48 | DA:59,2 49 | DA:60,2 50 | DA:61,2 51 | DA:62,2 52 | DA:63,2 53 | DA:64,2 54 | DA:65,2 55 | DA:66,2 56 | DA:67,2 57 | LF:37 58 | LH:37 59 | end_of_record 60 | SF:lib/data/failure.dart 61 | DA:5,2 62 | DA:7,1 63 | DA:8,2 64 | DA:12,4 65 | DA:16,2 66 | DA:20,0 67 | LF:6 68 | LH:5 69 | end_of_record 70 | SF:lib/domain/entities/weather.dart 71 | DA:4,7 72 | DA:22,3 73 | DA:23,3 74 | DA:24,3 75 | DA:25,3 76 | DA:26,3 77 | DA:27,3 78 | DA:28,3 79 | DA:29,3 80 | DA:30,3 81 | LF:10 82 | LH:10 83 | end_of_record 84 | SF:lib/domain/usecases/get_current_weather.dart 85 | DA:9,1 86 | DA:11,1 87 | DA:12,2 88 | LF:3 89 | LH:3 90 | end_of_record 91 | SF:lib/presentation/bloc/weather_bloc.dart 92 | DA:9,3 93 | DA:10,2 94 | DA:11,1 95 | DA:13,2 96 | DA:15,3 97 | DA:16,1 98 | DA:17,1 99 | DA:18,3 100 | DA:20,1 101 | DA:21,2 102 | LF:10 103 | LH:10 104 | end_of_record 105 | SF:lib/presentation/bloc/weather_event.dart 106 | DA:4,2 107 | DA:6,0 108 | DA:7,0 109 | DA:13,2 110 | DA:15,1 111 | DA:16,2 112 | LF:6 113 | LH:4 114 | end_of_record 115 | SF:lib/presentation/bloc/weather_state.dart 116 | DA:5,2 117 | DA:7,1 118 | DA:8,1 119 | DA:18,1 120 | DA:20,1 121 | DA:21,2 122 | DA:27,2 123 | DA:29,1 124 | DA:30,2 125 | LF:9 126 | LH:9 127 | end_of_record 128 | SF:lib/presentation/pages/weather_page.dart 129 | DA:9,2 130 | DA:11,1 131 | DA:13,1 132 | DA:14,1 133 | DA:16,1 134 | DA:18,1 135 | DA:21,1 136 | DA:23,1 137 | DA:25,1 138 | DA:26,1 139 | DA:28,1 140 | DA:31,1 141 | DA:32,3 142 | DA:35,1 143 | DA:36,1 144 | DA:37,1 145 | DA:38,1 146 | DA:39,1 147 | DA:40,1 148 | DA:42,1 149 | DA:43,1 150 | DA:44,1 151 | DA:45,1 152 | DA:46,1 153 | DA:48,1 154 | DA:49,1 155 | DA:50,2 156 | DA:51,1 157 | DA:55,1 158 | DA:56,1 159 | DA:57,1 160 | DA:58,2 161 | DA:64,1 162 | DA:65,1 163 | DA:66,5 164 | DA:67,1 165 | DA:72,1 166 | DA:73,1 167 | DA:74,1 168 | DA:75,1 169 | DA:80,1 170 | DA:81,2 171 | DA:82,1 172 | DA:84,1 173 | DA:86,1 174 | DA:92,1 175 | DA:94,1 176 | DA:95,3 177 | DA:96,1 178 | DA:104,2 179 | DA:105,1 180 | DA:107,1 181 | DA:109,1 182 | DA:115,1 183 | DA:117,1 184 | DA:118,3 185 | DA:119,1 186 | DA:126,2 187 | DA:127,1 188 | DA:129,1 189 | DA:131,1 190 | DA:137,1 191 | DA:139,1 192 | DA:140,3 193 | DA:141,1 194 | DA:153,1 195 | DA:154,0 196 | DA:155,0 197 | DA:158,1 198 | LF:69 199 | LH:67 200 | end_of_record 201 | SF:lib/data/repositories/weather_repository_impl.dart 202 | DA:13,1 203 | DA:16,1 204 | DA:18,3 205 | DA:19,2 206 | DA:20,1 207 | DA:21,2 208 | DA:22,1 209 | DA:23,2 210 | LF:8 211 | LH:8 212 | end_of_record 213 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/ephemeral/ 22 | Flutter/app.flx 23 | Flutter/app.zip 24 | Flutter/flutter_assets/ 25 | Flutter/flutter_export_environment.sh 26 | ServiceDefinitions.json 27 | Runner/GeneratedPluginRegistrant.* 28 | 29 | # Exceptions to above rules. 30 | !default.mode1v3 31 | !default.mode2v3 32 | !default.pbxuser 33 | !default.perspectivev3 34 | -------------------------------------------------------------------------------- /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 | 8.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.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1020; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | ENABLE_BITCODE = NO; 292 | INFOPLIST_FILE = Runner/Info.plist; 293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 294 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeatherAppSample; 295 | PRODUCT_NAME = "$(TARGET_NAME)"; 296 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 297 | SWIFT_VERSION = 5.0; 298 | VERSIONING_SYSTEM = "apple-generic"; 299 | }; 300 | name = Profile; 301 | }; 302 | 97C147031CF9000F007C117D /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ALWAYS_SEARCH_USER_PATHS = NO; 306 | CLANG_ANALYZER_NONNULL = YES; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_COMMA = YES; 314 | CLANG_WARN_CONSTANT_CONVERSION = YES; 315 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INFINITE_RECURSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 323 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 326 | CLANG_WARN_STRICT_PROTOTYPES = YES; 327 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = NO; 332 | DEBUG_INFORMATION_FORMAT = dwarf; 333 | ENABLE_STRICT_OBJC_MSGSEND = YES; 334 | ENABLE_TESTABILITY = YES; 335 | GCC_C_LANGUAGE_STANDARD = gnu99; 336 | GCC_DYNAMIC_NO_PIC = NO; 337 | GCC_NO_COMMON_BLOCKS = YES; 338 | GCC_OPTIMIZATION_LEVEL = 0; 339 | GCC_PREPROCESSOR_DEFINITIONS = ( 340 | "DEBUG=1", 341 | "$(inherited)", 342 | ); 343 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 344 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 345 | GCC_WARN_UNDECLARED_SELECTOR = YES; 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 347 | GCC_WARN_UNUSED_FUNCTION = YES; 348 | GCC_WARN_UNUSED_VARIABLE = YES; 349 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 350 | MTL_ENABLE_DEBUG_INFO = YES; 351 | ONLY_ACTIVE_ARCH = YES; 352 | SDKROOT = iphoneos; 353 | TARGETED_DEVICE_FAMILY = "1,2"; 354 | }; 355 | name = Debug; 356 | }; 357 | 97C147041CF9000F007C117D /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ALWAYS_SEARCH_USER_PATHS = NO; 361 | CLANG_ANALYZER_NONNULL = YES; 362 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 363 | CLANG_CXX_LIBRARY = "libc++"; 364 | CLANG_ENABLE_MODULES = YES; 365 | CLANG_ENABLE_OBJC_ARC = YES; 366 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_COMMA = YES; 369 | CLANG_WARN_CONSTANT_CONVERSION = YES; 370 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_EMPTY_BODY = YES; 373 | CLANG_WARN_ENUM_CONVERSION = YES; 374 | CLANG_WARN_INFINITE_RECURSION = YES; 375 | CLANG_WARN_INT_CONVERSION = YES; 376 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 377 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 378 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 379 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 380 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 381 | CLANG_WARN_STRICT_PROTOTYPES = YES; 382 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 383 | CLANG_WARN_UNREACHABLE_CODE = YES; 384 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 385 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 386 | COPY_PHASE_STRIP = NO; 387 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 388 | ENABLE_NS_ASSERTIONS = NO; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_NO_COMMON_BLOCKS = YES; 392 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 393 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 394 | GCC_WARN_UNDECLARED_SELECTOR = YES; 395 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 396 | GCC_WARN_UNUSED_FUNCTION = YES; 397 | GCC_WARN_UNUSED_VARIABLE = YES; 398 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 399 | MTL_ENABLE_DEBUG_INFO = NO; 400 | SDKROOT = iphoneos; 401 | SUPPORTED_PLATFORMS = iphoneos; 402 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 403 | TARGETED_DEVICE_FAMILY = "1,2"; 404 | VALIDATE_PRODUCT = YES; 405 | }; 406 | name = Release; 407 | }; 408 | 97C147061CF9000F007C117D /* Debug */ = { 409 | isa = XCBuildConfiguration; 410 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 411 | buildSettings = { 412 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 413 | CLANG_ENABLE_MODULES = YES; 414 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 415 | ENABLE_BITCODE = NO; 416 | INFOPLIST_FILE = Runner/Info.plist; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeatherAppSample; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 422 | SWIFT_VERSION = 5.0; 423 | VERSIONING_SYSTEM = "apple-generic"; 424 | }; 425 | name = Debug; 426 | }; 427 | 97C147071CF9000F007C117D /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | CLANG_ENABLE_MODULES = YES; 433 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 434 | ENABLE_BITCODE = NO; 435 | INFOPLIST_FILE = Runner/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 437 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWeatherAppSample; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 440 | SWIFT_VERSION = 5.0; 441 | VERSIONING_SYSTEM = "apple-generic"; 442 | }; 443 | name = Release; 444 | }; 445 | /* End XCBuildConfiguration section */ 446 | 447 | /* Begin XCConfigurationList section */ 448 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | 97C147031CF9000F007C117D /* Debug */, 452 | 97C147041CF9000F007C117D /* Release */, 453 | 249021D3217E4FDB00AE95B9 /* Profile */, 454 | ); 455 | defaultConfigurationIsVisible = 0; 456 | defaultConfigurationName = Release; 457 | }; 458 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 459 | isa = XCConfigurationList; 460 | buildConfigurations = ( 461 | 97C147061CF9000F007C117D /* Debug */, 462 | 97C147071CF9000F007C117D /* Release */, 463 | 249021D4217E4FDB00AE95B9 /* Profile */, 464 | ); 465 | defaultConfigurationIsVisible = 0; 466 | defaultConfigurationName = Release; 467 | }; 468 | /* End XCConfigurationList section */ 469 | }; 470 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 471 | } 472 | -------------------------------------------------------------------------------- /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 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/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 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_weather_app_sample 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/data/constants.dart: -------------------------------------------------------------------------------- 1 | class Urls { 2 | static const String baseUrl = 'https://api.openweathermap.org/data/2.5'; 3 | static const String apiKey = 'cc95d932d5a45d33a9527d5019475f2c'; 4 | static String currentWeatherByName(String city) => 5 | '$baseUrl/weather?q=$city&appid=$apiKey'; 6 | static String weatherIcon(String iconCode) => 7 | 'http://openweathermap.org/img/wn/$iconCode@2x.png'; 8 | } 9 | -------------------------------------------------------------------------------- /lib/data/datasources/remote_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_weather_app_sample/data/constants.dart'; 4 | import 'package:flutter_weather_app_sample/data/exception.dart'; 5 | import 'package:flutter_weather_app_sample/data/models/weather_model.dart'; 6 | import 'package:http/http.dart' as http; 7 | 8 | abstract class RemoteDataSource { 9 | Future getCurrentWeather(String cityName); 10 | } 11 | 12 | class RemoteDataSourceImpl implements RemoteDataSource { 13 | final http.Client client; 14 | RemoteDataSourceImpl({required this.client}); 15 | 16 | @override 17 | Future getCurrentWeather(String cityName) async { 18 | final response = 19 | await client.get(Uri.parse(Urls.currentWeatherByName(cityName))); 20 | 21 | if (response.statusCode == 200) { 22 | return WeatherModel.fromJson(json.decode(response.body)); 23 | } else { 24 | throw ServerException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/data/exception.dart: -------------------------------------------------------------------------------- 1 | class ServerException implements Exception {} 2 | -------------------------------------------------------------------------------- /lib/data/failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | abstract class Failure extends Equatable { 4 | final String message; 5 | const Failure(this.message); 6 | 7 | @override 8 | List get props => [message]; 9 | } 10 | 11 | class ServerFailure extends Failure { 12 | const ServerFailure(String message) : super(message); 13 | } 14 | 15 | class ConnectionFailure extends Failure { 16 | const ConnectionFailure(String message) : super(message); 17 | } 18 | 19 | class DatabaseFailure extends Failure { 20 | const DatabaseFailure(String message) : super(message); 21 | } 22 | -------------------------------------------------------------------------------- /lib/data/models/weather_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 3 | 4 | class WeatherModel extends Equatable { 5 | const WeatherModel({ 6 | required this.cityName, 7 | required this.main, 8 | required this.description, 9 | required this.iconCode, 10 | required this.temperature, 11 | required this.pressure, 12 | required this.humidity, 13 | }); 14 | 15 | final String cityName; 16 | final String main; 17 | final String description; 18 | final String iconCode; 19 | final double temperature; 20 | final int pressure; 21 | final int humidity; 22 | 23 | factory WeatherModel.fromJson(Map json) => WeatherModel( 24 | cityName: json['name'], 25 | main: json['weather'][0]['main'], 26 | description: json['weather'][0]['description'], 27 | iconCode: json['weather'][0]['icon'], 28 | temperature: json['main']['temp'], 29 | pressure: json['main']['pressure'], 30 | humidity: json['main']['humidity'], 31 | ); 32 | 33 | Map toJson() => { 34 | 'weather': [ 35 | { 36 | 'main': main, 37 | 'description': description, 38 | 'icon': iconCode, 39 | }, 40 | ], 41 | 'main': { 42 | 'temp': temperature, 43 | 'pressure': pressure, 44 | 'humidity': humidity, 45 | }, 46 | 'name': cityName, 47 | }; 48 | 49 | Weather toEntity() => Weather( 50 | cityName: cityName, 51 | main: main, 52 | description: description, 53 | iconCode: iconCode, 54 | temperature: temperature, 55 | pressure: pressure, 56 | humidity: humidity, 57 | ); 58 | 59 | @override 60 | List get props => [ 61 | cityName, 62 | main, 63 | description, 64 | iconCode, 65 | temperature, 66 | pressure, 67 | humidity, 68 | ]; 69 | } 70 | -------------------------------------------------------------------------------- /lib/data/repositories/weather_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter_weather_app_sample/data/datasources/remote_data_source.dart'; 4 | import 'package:flutter_weather_app_sample/data/exception.dart'; 5 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 6 | import 'package:flutter_weather_app_sample/data/failure.dart'; 7 | import 'package:dartz/dartz.dart'; 8 | import 'package:flutter_weather_app_sample/domain/repositories/weather_repository.dart'; 9 | 10 | class WeatherRepositoryImpl implements WeatherRepository { 11 | final RemoteDataSource remoteDataSource; 12 | 13 | WeatherRepositoryImpl({required this.remoteDataSource}); 14 | 15 | @override 16 | Future> getCurrentWeather(String cityName) async { 17 | try { 18 | final result = await remoteDataSource.getCurrentWeather(cityName); 19 | return Right(result.toEntity()); 20 | } on ServerException { 21 | return Left(ServerFailure('')); 22 | } on SocketException { 23 | return Left(ConnectionFailure('Failed to connect to the network')); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/domain/entities/weather.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class Weather extends Equatable { 4 | const Weather({ 5 | required this.cityName, 6 | required this.main, 7 | required this.description, 8 | required this.iconCode, 9 | required this.temperature, 10 | required this.pressure, 11 | required this.humidity, 12 | }); 13 | 14 | final String cityName; 15 | final String main; 16 | final String description; 17 | final String iconCode; 18 | final double temperature; 19 | final int pressure; 20 | final int humidity; 21 | 22 | @override 23 | List get props => [ 24 | cityName, 25 | main, 26 | description, 27 | iconCode, 28 | temperature, 29 | pressure, 30 | humidity, 31 | ]; 32 | } 33 | -------------------------------------------------------------------------------- /lib/domain/repositories/weather_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_weather_app_sample/data/failure.dart'; 3 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 4 | 5 | abstract class WeatherRepository { 6 | Future> getCurrentWeather(String cityName); 7 | } 8 | -------------------------------------------------------------------------------- /lib/domain/usecases/get_current_weather.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_weather_app_sample/data/failure.dart'; 3 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 4 | import 'package:flutter_weather_app_sample/domain/repositories/weather_repository.dart'; 5 | 6 | class GetCurrentWeather { 7 | final WeatherRepository repository; 8 | 9 | GetCurrentWeather(this.repository); 10 | 11 | Future> execute(String cityName) { 12 | return repository.getCurrentWeather(cityName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_weather_app_sample/data/datasources/remote_data_source.dart'; 2 | import 'package:flutter_weather_app_sample/data/repositories/weather_repository_impl.dart'; 3 | import 'package:flutter_weather_app_sample/domain/repositories/weather_repository.dart'; 4 | import 'package:flutter_weather_app_sample/domain/usecases/get_current_weather.dart'; 5 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_bloc.dart'; 6 | import 'package:http/http.dart' as http; 7 | import 'package:get_it/get_it.dart'; 8 | 9 | final locator = GetIt.instance; 10 | 11 | void init() { 12 | // bloc 13 | locator.registerFactory(() => WeatherBloc(locator())); 14 | 15 | // usecase 16 | locator.registerLazySingleton(() => GetCurrentWeather(locator())); 17 | 18 | // repository 19 | locator.registerLazySingleton( 20 | () => WeatherRepositoryImpl( 21 | remoteDataSource: locator(), 22 | ), 23 | ); 24 | 25 | // data source 26 | locator.registerLazySingleton( 27 | () => RemoteDataSourceImpl( 28 | client: locator(), 29 | ), 30 | ); 31 | 32 | // external 33 | locator.registerLazySingleton(() => http.Client()); 34 | } 35 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_bloc.dart'; 4 | import 'package:flutter_weather_app_sample/presentation/pages/weather_page.dart'; 5 | import 'injection.dart' as di; 6 | 7 | void main() { 8 | di.init(); 9 | runApp(MyApp()); 10 | } 11 | 12 | class MyApp extends StatelessWidget { 13 | @override 14 | Widget build(BuildContext context) { 15 | return MultiBlocProvider( 16 | providers: [ 17 | BlocProvider( 18 | create: (_) => di.locator(), 19 | ), 20 | ], 21 | child: MaterialApp( 22 | title: 'Flutter Demo', 23 | theme: ThemeData( 24 | primarySwatch: Colors.orange, 25 | ), 26 | home: WeatherPage(), 27 | ), 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/presentation/bloc/weather_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | import 'package:flutter_weather_app_sample/domain/usecases/get_current_weather.dart'; 3 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_event.dart'; 4 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_state.dart'; 5 | import 'package:rxdart/rxdart.dart'; 6 | 7 | class WeatherBloc extends Bloc { 8 | final GetCurrentWeather _getCurrentWeather; 9 | 10 | WeatherBloc(this._getCurrentWeather) : super(WeatherEmpty()) { 11 | on( 12 | (event, emit) async { 13 | final cityName = event.cityName; 14 | 15 | emit(WeatherLoading()); 16 | 17 | final result = await _getCurrentWeather.execute(cityName); 18 | result.fold( 19 | (failure) { 20 | emit(WeatherError(failure.message)); 21 | }, 22 | (data) { 23 | emit(WeatherHasData(data)); 24 | }, 25 | ); 26 | }, 27 | transformer: debounce(Duration(milliseconds: 500)), 28 | ); 29 | } 30 | 31 | EventTransformer debounce(Duration duration) { 32 | return (events, mapper) => events.debounceTime(duration).flatMap(mapper); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/presentation/bloc/weather_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | abstract class WeatherEvent extends Equatable { 4 | const WeatherEvent(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class OnCityChanged extends WeatherEvent { 11 | final String cityName; 12 | 13 | OnCityChanged(this.cityName); 14 | 15 | @override 16 | List get props => [cityName]; 17 | } 18 | -------------------------------------------------------------------------------- /lib/presentation/bloc/weather_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 3 | 4 | abstract class WeatherState extends Equatable { 5 | const WeatherState(); 6 | 7 | @override 8 | List get props => []; 9 | } 10 | 11 | class WeatherEmpty extends WeatherState {} 12 | 13 | class WeatherLoading extends WeatherState {} 14 | 15 | class WeatherError extends WeatherState { 16 | final String message; 17 | 18 | WeatherError(this.message); 19 | 20 | @override 21 | List get props => [message]; 22 | } 23 | 24 | class WeatherHasData extends WeatherState { 25 | final Weather result; 26 | 27 | WeatherHasData(this.result); 28 | 29 | @override 30 | List get props => [result]; 31 | } 32 | -------------------------------------------------------------------------------- /lib/presentation/pages/weather_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_weather_app_sample/data/constants.dart'; 4 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_bloc.dart'; 5 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_event.dart'; 6 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_state.dart'; 7 | 8 | class WeatherPage extends StatelessWidget { 9 | const WeatherPage({Key? key}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return Scaffold( 14 | appBar: AppBar( 15 | backgroundColor: Colors.white, 16 | title: Text( 17 | 'Weather', 18 | style: TextStyle(color: Colors.orange), 19 | ), 20 | ), 21 | body: Padding( 22 | padding: const EdgeInsets.all(24.0), 23 | child: Column( 24 | mainAxisAlignment: MainAxisAlignment.center, 25 | children: [ 26 | TextField( 27 | textAlign: TextAlign.center, 28 | decoration: InputDecoration( 29 | hintText: 'Enter city name', 30 | ), 31 | onChanged: (query) { 32 | context.read().add(OnCityChanged(query)); 33 | }, 34 | ), 35 | SizedBox(height: 32.0), 36 | BlocBuilder( 37 | builder: (context, state) { 38 | if (state is WeatherLoading) { 39 | return Center( 40 | child: CircularProgressIndicator(), 41 | ); 42 | } else if (state is WeatherHasData) { 43 | return Column( 44 | key: Key('weather_data'), 45 | children: [ 46 | Row( 47 | mainAxisAlignment: MainAxisAlignment.center, 48 | children: [ 49 | Text( 50 | state.result.cityName, 51 | style: TextStyle( 52 | fontSize: 22.0, 53 | ), 54 | ), 55 | Image( 56 | image: NetworkImage( 57 | Urls.weatherIcon( 58 | state.result.iconCode, 59 | ), 60 | ), 61 | ), 62 | ], 63 | ), 64 | SizedBox(height: 8.0), 65 | Text( 66 | '${state.result.main} | ${state.result.description}', 67 | style: TextStyle( 68 | fontSize: 16.0, 69 | letterSpacing: 1.2, 70 | ), 71 | ), 72 | SizedBox(height: 24.0), 73 | Table( 74 | defaultColumnWidth: FixedColumnWidth(150.0), 75 | border: TableBorder.all( 76 | color: Colors.grey, 77 | style: BorderStyle.solid, 78 | width: 1, 79 | ), 80 | children: [ 81 | TableRow(children: [ 82 | Padding( 83 | padding: const EdgeInsets.all(8.0), 84 | child: Text( 85 | 'Temperature', 86 | style: TextStyle( 87 | fontSize: 16.0, 88 | letterSpacing: 1.2, 89 | ), 90 | ), 91 | ), 92 | Padding( 93 | padding: const EdgeInsets.all(8.0), 94 | child: Text( 95 | state.result.temperature.toString(), 96 | style: TextStyle( 97 | fontSize: 16.0, 98 | letterSpacing: 1.2, 99 | fontWeight: FontWeight.bold, 100 | ), 101 | ), 102 | ), // Will be change later 103 | ]), 104 | TableRow(children: [ 105 | Padding( 106 | padding: const EdgeInsets.all(8.0), 107 | child: Text( 108 | 'Pressure', 109 | style: TextStyle( 110 | fontSize: 16.0, 111 | letterSpacing: 1.2, 112 | ), 113 | ), 114 | ), 115 | Padding( 116 | padding: const EdgeInsets.all(8.0), 117 | child: Text( 118 | state.result.pressure.toString(), 119 | style: TextStyle( 120 | fontSize: 16.0, 121 | letterSpacing: 1.2, 122 | fontWeight: FontWeight.bold), 123 | ), 124 | ), // Will be change later 125 | ]), 126 | TableRow(children: [ 127 | Padding( 128 | padding: const EdgeInsets.all(8.0), 129 | child: Text( 130 | 'Humidity', 131 | style: TextStyle( 132 | fontSize: 16.0, 133 | letterSpacing: 1.2, 134 | ), 135 | ), 136 | ), 137 | Padding( 138 | padding: const EdgeInsets.all(8.0), 139 | child: Text( 140 | state.result.humidity.toString(), 141 | style: TextStyle( 142 | fontSize: 16.0, 143 | letterSpacing: 1.2, 144 | fontWeight: FontWeight.bold, 145 | ), 146 | ), 147 | ), // Will be change later 148 | ]), 149 | ], 150 | ), 151 | ], 152 | ); 153 | } else if (state is WeatherError) { 154 | return Center( 155 | child: Text('Something went wrong!'), 156 | ); 157 | } else { 158 | return SizedBox(); 159 | } 160 | }, 161 | ), 162 | ], 163 | ), 164 | ), 165 | ); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "22.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.7.1" 18 | args: 19 | dependency: transitive 20 | description: 21 | name: args 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "2.3.0" 25 | async: 26 | dependency: transitive 27 | description: 28 | name: async 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.6.1" 32 | bloc: 33 | dependency: transitive 34 | description: 35 | name: bloc 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "8.0.2" 39 | bloc_test: 40 | dependency: "direct dev" 41 | description: 42 | name: bloc_test 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "9.0.2" 46 | boolean_selector: 47 | dependency: transitive 48 | description: 49 | name: boolean_selector 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "2.1.0" 53 | build: 54 | dependency: transitive 55 | description: 56 | name: build 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "2.1.0" 60 | build_config: 61 | dependency: transitive 62 | description: 63 | name: build_config 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.0.0" 67 | build_daemon: 68 | dependency: transitive 69 | description: 70 | name: build_daemon 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "3.0.0" 74 | build_resolvers: 75 | dependency: transitive 76 | description: 77 | name: build_resolvers 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "2.0.4" 81 | build_runner: 82 | dependency: "direct dev" 83 | description: 84 | name: build_runner 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "2.1.2" 88 | build_runner_core: 89 | dependency: transitive 90 | description: 91 | name: build_runner_core 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "7.1.0" 95 | built_collection: 96 | dependency: transitive 97 | description: 98 | name: built_collection 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "5.1.1" 102 | built_value: 103 | dependency: transitive 104 | description: 105 | name: built_value 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "8.1.4" 109 | characters: 110 | dependency: transitive 111 | description: 112 | name: characters 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "1.1.0" 116 | charcode: 117 | dependency: transitive 118 | description: 119 | name: charcode 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "1.2.0" 123 | checked_yaml: 124 | dependency: transitive 125 | description: 126 | name: checked_yaml 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "2.0.1" 130 | cli_util: 131 | dependency: transitive 132 | description: 133 | name: cli_util 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "0.3.5" 137 | clock: 138 | dependency: transitive 139 | description: 140 | name: clock 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "1.1.0" 144 | code_builder: 145 | dependency: transitive 146 | description: 147 | name: code_builder 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "4.1.0" 151 | collection: 152 | dependency: transitive 153 | description: 154 | name: collection 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "1.15.0" 158 | convert: 159 | dependency: transitive 160 | description: 161 | name: convert 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "3.0.1" 165 | coverage: 166 | dependency: transitive 167 | description: 168 | name: coverage 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "1.0.3" 172 | crypto: 173 | dependency: transitive 174 | description: 175 | name: crypto 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "3.0.1" 179 | cupertino_icons: 180 | dependency: "direct main" 181 | description: 182 | name: cupertino_icons 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "1.0.4" 186 | dart_style: 187 | dependency: transitive 188 | description: 189 | name: dart_style 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "2.1.1" 193 | dartz: 194 | dependency: "direct main" 195 | description: 196 | name: dartz 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "0.10.1" 200 | diff_match_patch: 201 | dependency: transitive 202 | description: 203 | name: diff_match_patch 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "0.4.1" 207 | equatable: 208 | dependency: "direct main" 209 | description: 210 | name: equatable 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "2.0.3" 214 | fake_async: 215 | dependency: transitive 216 | description: 217 | name: fake_async 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "1.2.0" 221 | file: 222 | dependency: transitive 223 | description: 224 | name: file 225 | url: "https://pub.dartlang.org" 226 | source: hosted 227 | version: "6.1.2" 228 | fixnum: 229 | dependency: transitive 230 | description: 231 | name: fixnum 232 | url: "https://pub.dartlang.org" 233 | source: hosted 234 | version: "1.0.0" 235 | flutter: 236 | dependency: "direct main" 237 | description: flutter 238 | source: sdk 239 | version: "0.0.0" 240 | flutter_bloc: 241 | dependency: "direct main" 242 | description: 243 | name: flutter_bloc 244 | url: "https://pub.dartlang.org" 245 | source: hosted 246 | version: "8.0.1" 247 | flutter_test: 248 | dependency: "direct dev" 249 | description: flutter 250 | source: sdk 251 | version: "0.0.0" 252 | frontend_server_client: 253 | dependency: transitive 254 | description: 255 | name: frontend_server_client 256 | url: "https://pub.dartlang.org" 257 | source: hosted 258 | version: "2.1.2" 259 | get_it: 260 | dependency: "direct main" 261 | description: 262 | name: get_it 263 | url: "https://pub.dartlang.org" 264 | source: hosted 265 | version: "7.2.0" 266 | glob: 267 | dependency: transitive 268 | description: 269 | name: glob 270 | url: "https://pub.dartlang.org" 271 | source: hosted 272 | version: "2.0.1" 273 | graphs: 274 | dependency: transitive 275 | description: 276 | name: graphs 277 | url: "https://pub.dartlang.org" 278 | source: hosted 279 | version: "2.1.0" 280 | http: 281 | dependency: "direct main" 282 | description: 283 | name: http 284 | url: "https://pub.dartlang.org" 285 | source: hosted 286 | version: "0.13.3" 287 | http_multi_server: 288 | dependency: transitive 289 | description: 290 | name: http_multi_server 291 | url: "https://pub.dartlang.org" 292 | source: hosted 293 | version: "3.0.1" 294 | http_parser: 295 | dependency: transitive 296 | description: 297 | name: http_parser 298 | url: "https://pub.dartlang.org" 299 | source: hosted 300 | version: "4.0.0" 301 | io: 302 | dependency: transitive 303 | description: 304 | name: io 305 | url: "https://pub.dartlang.org" 306 | source: hosted 307 | version: "1.0.3" 308 | js: 309 | dependency: transitive 310 | description: 311 | name: js 312 | url: "https://pub.dartlang.org" 313 | source: hosted 314 | version: "0.6.3" 315 | json_annotation: 316 | dependency: transitive 317 | description: 318 | name: json_annotation 319 | url: "https://pub.dartlang.org" 320 | source: hosted 321 | version: "4.0.1" 322 | logging: 323 | dependency: transitive 324 | description: 325 | name: logging 326 | url: "https://pub.dartlang.org" 327 | source: hosted 328 | version: "1.0.2" 329 | matcher: 330 | dependency: transitive 331 | description: 332 | name: matcher 333 | url: "https://pub.dartlang.org" 334 | source: hosted 335 | version: "0.12.10" 336 | meta: 337 | dependency: transitive 338 | description: 339 | name: meta 340 | url: "https://pub.dartlang.org" 341 | source: hosted 342 | version: "1.3.0" 343 | mime: 344 | dependency: transitive 345 | description: 346 | name: mime 347 | url: "https://pub.dartlang.org" 348 | source: hosted 349 | version: "1.0.1" 350 | mockito: 351 | dependency: "direct dev" 352 | description: 353 | name: mockito 354 | url: "https://pub.dartlang.org" 355 | source: hosted 356 | version: "5.0.15" 357 | mocktail: 358 | dependency: "direct dev" 359 | description: 360 | name: mocktail 361 | url: "https://pub.dartlang.org" 362 | source: hosted 363 | version: "0.2.0" 364 | nested: 365 | dependency: transitive 366 | description: 367 | name: nested 368 | url: "https://pub.dartlang.org" 369 | source: hosted 370 | version: "1.0.0" 371 | node_preamble: 372 | dependency: transitive 373 | description: 374 | name: node_preamble 375 | url: "https://pub.dartlang.org" 376 | source: hosted 377 | version: "2.0.1" 378 | package_config: 379 | dependency: transitive 380 | description: 381 | name: package_config 382 | url: "https://pub.dartlang.org" 383 | source: hosted 384 | version: "2.0.2" 385 | path: 386 | dependency: transitive 387 | description: 388 | name: path 389 | url: "https://pub.dartlang.org" 390 | source: hosted 391 | version: "1.8.0" 392 | pedantic: 393 | dependency: transitive 394 | description: 395 | name: pedantic 396 | url: "https://pub.dartlang.org" 397 | source: hosted 398 | version: "1.11.1" 399 | pool: 400 | dependency: transitive 401 | description: 402 | name: pool 403 | url: "https://pub.dartlang.org" 404 | source: hosted 405 | version: "1.5.0" 406 | provider: 407 | dependency: transitive 408 | description: 409 | name: provider 410 | url: "https://pub.dartlang.org" 411 | source: hosted 412 | version: "6.0.2" 413 | pub_semver: 414 | dependency: transitive 415 | description: 416 | name: pub_semver 417 | url: "https://pub.dartlang.org" 418 | source: hosted 419 | version: "2.1.0" 420 | pubspec_parse: 421 | dependency: transitive 422 | description: 423 | name: pubspec_parse 424 | url: "https://pub.dartlang.org" 425 | source: hosted 426 | version: "1.0.0" 427 | rxdart: 428 | dependency: "direct main" 429 | description: 430 | name: rxdart 431 | url: "https://pub.dartlang.org" 432 | source: hosted 433 | version: "0.27.3" 434 | shelf: 435 | dependency: transitive 436 | description: 437 | name: shelf 438 | url: "https://pub.dartlang.org" 439 | source: hosted 440 | version: "1.2.0" 441 | shelf_packages_handler: 442 | dependency: transitive 443 | description: 444 | name: shelf_packages_handler 445 | url: "https://pub.dartlang.org" 446 | source: hosted 447 | version: "3.0.0" 448 | shelf_static: 449 | dependency: transitive 450 | description: 451 | name: shelf_static 452 | url: "https://pub.dartlang.org" 453 | source: hosted 454 | version: "1.1.0" 455 | shelf_web_socket: 456 | dependency: transitive 457 | description: 458 | name: shelf_web_socket 459 | url: "https://pub.dartlang.org" 460 | source: hosted 461 | version: "1.0.1" 462 | sky_engine: 463 | dependency: transitive 464 | description: flutter 465 | source: sdk 466 | version: "0.0.99" 467 | source_gen: 468 | dependency: transitive 469 | description: 470 | name: source_gen 471 | url: "https://pub.dartlang.org" 472 | source: hosted 473 | version: "1.0.3" 474 | source_map_stack_trace: 475 | dependency: transitive 476 | description: 477 | name: source_map_stack_trace 478 | url: "https://pub.dartlang.org" 479 | source: hosted 480 | version: "2.1.0" 481 | source_maps: 482 | dependency: transitive 483 | description: 484 | name: source_maps 485 | url: "https://pub.dartlang.org" 486 | source: hosted 487 | version: "0.10.10" 488 | source_span: 489 | dependency: transitive 490 | description: 491 | name: source_span 492 | url: "https://pub.dartlang.org" 493 | source: hosted 494 | version: "1.8.1" 495 | stack_trace: 496 | dependency: transitive 497 | description: 498 | name: stack_trace 499 | url: "https://pub.dartlang.org" 500 | source: hosted 501 | version: "1.10.0" 502 | stream_channel: 503 | dependency: transitive 504 | description: 505 | name: stream_channel 506 | url: "https://pub.dartlang.org" 507 | source: hosted 508 | version: "2.1.0" 509 | stream_transform: 510 | dependency: transitive 511 | description: 512 | name: stream_transform 513 | url: "https://pub.dartlang.org" 514 | source: hosted 515 | version: "2.0.0" 516 | string_scanner: 517 | dependency: transitive 518 | description: 519 | name: string_scanner 520 | url: "https://pub.dartlang.org" 521 | source: hosted 522 | version: "1.1.0" 523 | term_glyph: 524 | dependency: transitive 525 | description: 526 | name: term_glyph 527 | url: "https://pub.dartlang.org" 528 | source: hosted 529 | version: "1.2.0" 530 | test: 531 | dependency: transitive 532 | description: 533 | name: test 534 | url: "https://pub.dartlang.org" 535 | source: hosted 536 | version: "1.16.8" 537 | test_api: 538 | dependency: transitive 539 | description: 540 | name: test_api 541 | url: "https://pub.dartlang.org" 542 | source: hosted 543 | version: "0.3.0" 544 | test_core: 545 | dependency: transitive 546 | description: 547 | name: test_core 548 | url: "https://pub.dartlang.org" 549 | source: hosted 550 | version: "0.3.19" 551 | timing: 552 | dependency: transitive 553 | description: 554 | name: timing 555 | url: "https://pub.dartlang.org" 556 | source: hosted 557 | version: "1.0.0" 558 | typed_data: 559 | dependency: transitive 560 | description: 561 | name: typed_data 562 | url: "https://pub.dartlang.org" 563 | source: hosted 564 | version: "1.3.0" 565 | vector_math: 566 | dependency: transitive 567 | description: 568 | name: vector_math 569 | url: "https://pub.dartlang.org" 570 | source: hosted 571 | version: "2.1.0" 572 | vm_service: 573 | dependency: transitive 574 | description: 575 | name: vm_service 576 | url: "https://pub.dartlang.org" 577 | source: hosted 578 | version: "6.2.0" 579 | watcher: 580 | dependency: transitive 581 | description: 582 | name: watcher 583 | url: "https://pub.dartlang.org" 584 | source: hosted 585 | version: "1.0.0" 586 | web_socket_channel: 587 | dependency: transitive 588 | description: 589 | name: web_socket_channel 590 | url: "https://pub.dartlang.org" 591 | source: hosted 592 | version: "2.1.0" 593 | webkit_inspection_protocol: 594 | dependency: transitive 595 | description: 596 | name: webkit_inspection_protocol 597 | url: "https://pub.dartlang.org" 598 | source: hosted 599 | version: "1.0.0" 600 | yaml: 601 | dependency: transitive 602 | description: 603 | name: yaml 604 | url: "https://pub.dartlang.org" 605 | source: hosted 606 | version: "3.1.0" 607 | sdks: 608 | dart: ">=2.12.0 <3.0.0" 609 | flutter: ">=1.16.0" 610 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_weather_app_sample 2 | description: A new Flutter project. 3 | 4 | publish_to: 'none' 5 | 6 | version: 1.0.0+1 7 | 8 | environment: 9 | sdk: ">=2.12.0 <3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | cupertino_icons: ^1.0.2 16 | dartz: ^0.10.1 17 | equatable: ^2.0.3 18 | flutter_bloc: ^8.0.1 19 | get_it: ^7.2.0 20 | http: ^0.13.3 21 | rxdart: ^0.27.3 22 | 23 | 24 | dev_dependencies: 25 | bloc_test: ^9.0.2 26 | build_runner: ^2.1.2 27 | flutter_test: 28 | sdk: flutter 29 | mockito: ^5.0.15 30 | mocktail: ^0.2.0 31 | 32 | flutter: 33 | 34 | uses-material-design: true 35 | 36 | # To add assets to your application, add an assets section, like this: 37 | # assets: 38 | # - images/a_dot_burr.jpeg 39 | # - images/a_dot_ham.jpeg 40 | -------------------------------------------------------------------------------- /test/data/datasources/remote_data_source_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:flutter_weather_app_sample/data/constants.dart'; 5 | import 'package:flutter_weather_app_sample/data/datasources/remote_data_source.dart'; 6 | import 'package:flutter_weather_app_sample/data/exception.dart'; 7 | import 'package:flutter_weather_app_sample/data/models/weather_model.dart'; 8 | import 'package:http/http.dart' as http; 9 | import 'package:mockito/mockito.dart'; 10 | 11 | import '../../helpers/json_reader.dart'; 12 | import '../../helpers/test_helper.mocks.dart'; 13 | 14 | void main() { 15 | late MockHttpClient mockHttpClient; 16 | late RemoteDataSourceImpl dataSource; 17 | 18 | setUp(() { 19 | mockHttpClient = MockHttpClient(); 20 | dataSource = RemoteDataSourceImpl(client: mockHttpClient); 21 | }); 22 | 23 | group('get current weather', () { 24 | final tCityName = 'Jakarta'; 25 | final tWeatherModel = WeatherModel.fromJson(json 26 | .decode(readJson('helpers/dummy_data/dummy_weather_response.json'))); 27 | 28 | test( 29 | 'should return weather model when the response code is 200', 30 | () async { 31 | // arrange 32 | when( 33 | mockHttpClient.get(Uri.parse(Urls.currentWeatherByName(tCityName))), 34 | ).thenAnswer( 35 | (_) async => http.Response( 36 | readJson('helpers/dummy_data/dummy_weather_response.json'), 200), 37 | ); 38 | 39 | // act 40 | final result = await dataSource.getCurrentWeather(tCityName); 41 | 42 | // assert 43 | expect(result, equals(tWeatherModel)); 44 | }, 45 | ); 46 | 47 | test( 48 | 'should throw a server exception when the response code is 404 or other', 49 | () async { 50 | // arrange 51 | when( 52 | mockHttpClient.get(Uri.parse(Urls.currentWeatherByName(tCityName))), 53 | ).thenAnswer( 54 | (_) async => http.Response('Not found', 404), 55 | ); 56 | 57 | // act 58 | final call = dataSource.getCurrentWeather(tCityName); 59 | 60 | // assert 61 | expect(() => call, throwsA(isA())); 62 | }, 63 | ); 64 | }); 65 | } 66 | -------------------------------------------------------------------------------- /test/data/models/weather_model_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:flutter_weather_app_sample/data/models/weather_model.dart'; 5 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 6 | 7 | import '../../helpers/json_reader.dart'; 8 | 9 | void main() { 10 | const tWeatherModel = WeatherModel( 11 | cityName: 'Jakarta', 12 | main: 'Clouds', 13 | description: 'few clouds', 14 | iconCode: '02d', 15 | temperature: 302.28, 16 | pressure: 1009, 17 | humidity: 70, 18 | ); 19 | 20 | const tWeather = Weather( 21 | cityName: 'Jakarta', 22 | main: 'Clouds', 23 | description: 'few clouds', 24 | iconCode: '02d', 25 | temperature: 302.28, 26 | pressure: 1009, 27 | humidity: 70, 28 | ); 29 | 30 | group('to entity', () { 31 | test( 32 | 'should be a subclass of weather entity', 33 | () async { 34 | // assert 35 | final result = tWeatherModel.toEntity(); 36 | expect(result, equals(tWeather)); 37 | }, 38 | ); 39 | }); 40 | 41 | group('from json', () { 42 | test( 43 | 'should return a valid model from json', 44 | () async { 45 | // arrange 46 | final Map jsonMap = json.decode( 47 | readJson('helpers/dummy_data/dummy_weather_response.json'), 48 | ); 49 | 50 | // act 51 | final result = WeatherModel.fromJson(jsonMap); 52 | 53 | // assert 54 | expect(result, equals(tWeatherModel)); 55 | }, 56 | ); 57 | }); 58 | 59 | group('to json', () { 60 | test( 61 | 'should return a json map containing proper data', 62 | () async { 63 | // act 64 | final result = tWeatherModel.toJson(); 65 | 66 | // assert 67 | final expectedJsonMap = { 68 | 'weather': [ 69 | { 70 | 'main': 'Clouds', 71 | 'description': 'few clouds', 72 | 'icon': '02d', 73 | } 74 | ], 75 | 'main': { 76 | 'temp': 302.28, 77 | 'pressure': 1009, 78 | 'humidity': 70, 79 | }, 80 | 'name': 'Jakarta', 81 | }; 82 | expect(result, equals(expectedJsonMap)); 83 | }, 84 | ); 85 | }); 86 | } 87 | -------------------------------------------------------------------------------- /test/data/repositories/weather_repository_impl_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dartz/dartz.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:flutter_weather_app_sample/data/exception.dart'; 6 | import 'package:flutter_weather_app_sample/data/failure.dart'; 7 | import 'package:flutter_weather_app_sample/data/models/weather_model.dart'; 8 | import 'package:flutter_weather_app_sample/data/repositories/weather_repository_impl.dart'; 9 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 10 | import 'package:mockito/mockito.dart'; 11 | 12 | import '../../helpers/test_helper.mocks.dart'; 13 | 14 | void main() { 15 | late MockRemoteDataSource mockRemoteDataSource; 16 | late WeatherRepositoryImpl repository; 17 | 18 | setUp(() { 19 | mockRemoteDataSource = MockRemoteDataSource(); 20 | repository = WeatherRepositoryImpl( 21 | remoteDataSource: mockRemoteDataSource, 22 | ); 23 | }); 24 | 25 | const tWeatherModel = WeatherModel( 26 | cityName: 'Jakarta', 27 | main: 'Clouds', 28 | description: 'few clouds', 29 | iconCode: '02d', 30 | temperature: 302.28, 31 | pressure: 1009, 32 | humidity: 70, 33 | ); 34 | 35 | const tWeather = Weather( 36 | cityName: 'Jakarta', 37 | main: 'Clouds', 38 | description: 'few clouds', 39 | iconCode: '02d', 40 | temperature: 302.28, 41 | pressure: 1009, 42 | humidity: 70, 43 | ); 44 | 45 | group('get current weather', () { 46 | final tCityName = 'Jakarta'; 47 | 48 | test( 49 | 'should return current weather when a call to data source is successful', 50 | () async { 51 | // arrange 52 | when(mockRemoteDataSource.getCurrentWeather(tCityName)) 53 | .thenAnswer((_) async => tWeatherModel); 54 | 55 | // act 56 | final result = await repository.getCurrentWeather(tCityName); 57 | 58 | // assert 59 | verify(mockRemoteDataSource.getCurrentWeather(tCityName)); 60 | expect(result, equals(Right(tWeather))); 61 | }, 62 | ); 63 | 64 | test( 65 | 'should return server failure when a call to data source is unsuccessful', 66 | () async { 67 | // arrange 68 | when(mockRemoteDataSource.getCurrentWeather(tCityName)) 69 | .thenThrow(ServerException()); 70 | 71 | // act 72 | final result = await repository.getCurrentWeather(tCityName); 73 | 74 | // assert 75 | verify(mockRemoteDataSource.getCurrentWeather(tCityName)); 76 | expect(result, equals(Left(ServerFailure('')))); 77 | }, 78 | ); 79 | 80 | test( 81 | 'should return connection failure when the device has no internet', 82 | () async { 83 | // arrange 84 | when(mockRemoteDataSource.getCurrentWeather(tCityName)) 85 | .thenThrow(SocketException('Failed to connect to the network')); 86 | 87 | // act 88 | final result = await repository.getCurrentWeather(tCityName); 89 | 90 | // assert 91 | verify(mockRemoteDataSource.getCurrentWeather(tCityName)); 92 | expect( 93 | result, 94 | equals(Left(ConnectionFailure('Failed to connect to the network'))), 95 | ); 96 | }, 97 | ); 98 | }); 99 | } 100 | -------------------------------------------------------------------------------- /test/domain/usecases/get_current_weather_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 4 | import 'package:flutter_weather_app_sample/domain/usecases/get_current_weather.dart'; 5 | import 'package:mockito/mockito.dart'; 6 | 7 | import '../../helpers/test_helper.mocks.dart'; 8 | 9 | void main() { 10 | late MockWeatherRepository mockWeatherRepository; 11 | late GetCurrentWeather usecase; 12 | 13 | setUp(() { 14 | mockWeatherRepository = MockWeatherRepository(); 15 | usecase = GetCurrentWeather(mockWeatherRepository); 16 | }); 17 | 18 | const testWeatherDetail = Weather( 19 | cityName: 'Jakarta', 20 | main: 'Clouds', 21 | description: 'few clouds', 22 | iconCode: '02d', 23 | temperature: 302.28, 24 | pressure: 1009, 25 | humidity: 70, 26 | ); 27 | 28 | const tCityName = 'Jakarta'; 29 | 30 | test( 31 | 'should get current weather detail from the repository', 32 | () async { 33 | // arrange 34 | when(mockWeatherRepository.getCurrentWeather(tCityName)) 35 | .thenAnswer((_) async => const Right(testWeatherDetail)); 36 | 37 | // act 38 | final result = await usecase.execute(tCityName); 39 | 40 | // assert 41 | expect(result, equals(Right(testWeatherDetail))); 42 | }, 43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /test/helpers/dummy_data/dummy_weather_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "coord": { 3 | "lon": 106.8451, 4 | "lat": -6.2146 5 | }, 6 | "weather": [ 7 | { 8 | "id": 801, 9 | "main": "Clouds", 10 | "description": "few clouds", 11 | "icon": "02d" 12 | } 13 | ], 14 | "base": "stations", 15 | "main": { 16 | "temp": 302.28, 17 | "feels_like": 306.16, 18 | "temp_min": 301.98, 19 | "temp_max": 304.51, 20 | "pressure": 1009, 21 | "humidity": 70 22 | }, 23 | "visibility": 6000, 24 | "wind": { 25 | "speed": 2.06, 26 | "deg": 240 27 | }, 28 | "clouds": { 29 | "all": 20 30 | }, 31 | "dt": 1642988670, 32 | "sys": { 33 | "type": 1, 34 | "id": 9383, 35 | "country": "ID", 36 | "sunrise": 1642978330, 37 | "sunset": 1643023003 38 | }, 39 | "timezone": 25200, 40 | "id": 1642911, 41 | "name": "Jakarta", 42 | "cod": 200 43 | } -------------------------------------------------------------------------------- /test/helpers/json_reader.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | String readJson(String name) { 4 | var dir = Directory.current.path; 5 | if (dir.endsWith('/test')) { 6 | dir = dir.replaceAll('/test', ''); 7 | } 8 | return File('$dir/test/$name').readAsStringSync(); 9 | } 10 | -------------------------------------------------------------------------------- /test/helpers/test_helper.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_weather_app_sample/data/datasources/remote_data_source.dart'; 2 | import 'package:flutter_weather_app_sample/domain/repositories/weather_repository.dart'; 3 | import 'package:mockito/annotations.dart'; 4 | import 'package:http/http.dart' as http; 5 | 6 | @GenerateMocks([ 7 | WeatherRepository, 8 | RemoteDataSource, 9 | ], customMocks: [ 10 | MockSpec(as: #MockHttpClient) 11 | ]) 12 | void main() {} 13 | -------------------------------------------------------------------------------- /test/helpers/test_helper.mocks.dart: -------------------------------------------------------------------------------- 1 | // Mocks generated by Mockito 5.0.15 from annotations 2 | // in flutter_weather_app_sample/test/helpers/test_helper.dart. 3 | // Do not manually edit this file. 4 | 5 | import 'dart:async' as _i6; 6 | import 'dart:convert' as _i10; 7 | import 'dart:typed_data' as _i11; 8 | 9 | import 'package:dartz/dartz.dart' as _i2; 10 | import 'package:flutter_weather_app_sample/data/datasources/remote_data_source.dart' 11 | as _i9; 12 | import 'package:flutter_weather_app_sample/data/failure.dart' as _i7; 13 | import 'package:flutter_weather_app_sample/data/models/weather_model.dart' 14 | as _i3; 15 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart' as _i8; 16 | import 'package:flutter_weather_app_sample/domain/repositories/weather_repository.dart' 17 | as _i5; 18 | import 'package:http/http.dart' as _i4; 19 | import 'package:mockito/mockito.dart' as _i1; 20 | 21 | // ignore_for_file: avoid_redundant_argument_values 22 | // ignore_for_file: avoid_setters_without_getters 23 | // ignore_for_file: comment_references 24 | // ignore_for_file: implementation_imports 25 | // ignore_for_file: invalid_use_of_visible_for_testing_member 26 | // ignore_for_file: prefer_const_constructors 27 | // ignore_for_file: unnecessary_parenthesis 28 | 29 | class _FakeEither_0 extends _i1.Fake implements _i2.Either {} 30 | 31 | class _FakeWeatherModel_1 extends _i1.Fake implements _i3.WeatherModel {} 32 | 33 | class _FakeResponse_2 extends _i1.Fake implements _i4.Response {} 34 | 35 | class _FakeStreamedResponse_3 extends _i1.Fake implements _i4.StreamedResponse { 36 | } 37 | 38 | /// A class which mocks [WeatherRepository]. 39 | /// 40 | /// See the documentation for Mockito's code generation for more information. 41 | class MockWeatherRepository extends _i1.Mock implements _i5.WeatherRepository { 42 | MockWeatherRepository() { 43 | _i1.throwOnMissingStub(this); 44 | } 45 | 46 | @override 47 | _i6.Future<_i2.Either<_i7.Failure, _i8.Weather>> getCurrentWeather( 48 | String? cityName) => 49 | (super.noSuchMethod(Invocation.method(#getCurrentWeather, [cityName]), 50 | returnValue: Future<_i2.Either<_i7.Failure, _i8.Weather>>.value( 51 | _FakeEither_0<_i7.Failure, _i8.Weather>())) 52 | as _i6.Future<_i2.Either<_i7.Failure, _i8.Weather>>); 53 | @override 54 | String toString() => super.toString(); 55 | } 56 | 57 | /// A class which mocks [RemoteDataSource]. 58 | /// 59 | /// See the documentation for Mockito's code generation for more information. 60 | class MockRemoteDataSource extends _i1.Mock implements _i9.RemoteDataSource { 61 | MockRemoteDataSource() { 62 | _i1.throwOnMissingStub(this); 63 | } 64 | 65 | @override 66 | _i6.Future<_i3.WeatherModel> getCurrentWeather(String? cityName) => 67 | (super.noSuchMethod(Invocation.method(#getCurrentWeather, [cityName]), 68 | returnValue: 69 | Future<_i3.WeatherModel>.value(_FakeWeatherModel_1())) 70 | as _i6.Future<_i3.WeatherModel>); 71 | @override 72 | String toString() => super.toString(); 73 | } 74 | 75 | /// A class which mocks [Client]. 76 | /// 77 | /// See the documentation for Mockito's code generation for more information. 78 | class MockHttpClient extends _i1.Mock implements _i4.Client { 79 | MockHttpClient() { 80 | _i1.throwOnMissingStub(this); 81 | } 82 | 83 | @override 84 | _i6.Future<_i4.Response> head(Uri? url, {Map? headers}) => 85 | (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}), 86 | returnValue: Future<_i4.Response>.value(_FakeResponse_2())) 87 | as _i6.Future<_i4.Response>); 88 | @override 89 | _i6.Future<_i4.Response> get(Uri? url, {Map? headers}) => 90 | (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), 91 | returnValue: Future<_i4.Response>.value(_FakeResponse_2())) 92 | as _i6.Future<_i4.Response>); 93 | @override 94 | _i6.Future<_i4.Response> post(Uri? url, 95 | {Map? headers, 96 | Object? body, 97 | _i10.Encoding? encoding}) => 98 | (super.noSuchMethod( 99 | Invocation.method(#post, [url], 100 | {#headers: headers, #body: body, #encoding: encoding}), 101 | returnValue: Future<_i4.Response>.value(_FakeResponse_2())) 102 | as _i6.Future<_i4.Response>); 103 | @override 104 | _i6.Future<_i4.Response> put(Uri? url, 105 | {Map? headers, 106 | Object? body, 107 | _i10.Encoding? encoding}) => 108 | (super.noSuchMethod( 109 | Invocation.method(#put, [url], 110 | {#headers: headers, #body: body, #encoding: encoding}), 111 | returnValue: Future<_i4.Response>.value(_FakeResponse_2())) 112 | as _i6.Future<_i4.Response>); 113 | @override 114 | _i6.Future<_i4.Response> patch(Uri? url, 115 | {Map? headers, 116 | Object? body, 117 | _i10.Encoding? encoding}) => 118 | (super.noSuchMethod( 119 | Invocation.method(#patch, [url], 120 | {#headers: headers, #body: body, #encoding: encoding}), 121 | returnValue: Future<_i4.Response>.value(_FakeResponse_2())) 122 | as _i6.Future<_i4.Response>); 123 | @override 124 | _i6.Future<_i4.Response> delete(Uri? url, 125 | {Map? headers, 126 | Object? body, 127 | _i10.Encoding? encoding}) => 128 | (super.noSuchMethod( 129 | Invocation.method(#delete, [url], 130 | {#headers: headers, #body: body, #encoding: encoding}), 131 | returnValue: Future<_i4.Response>.value(_FakeResponse_2())) 132 | as _i6.Future<_i4.Response>); 133 | @override 134 | _i6.Future read(Uri? url, {Map? headers}) => 135 | (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}), 136 | returnValue: Future.value('')) as _i6.Future); 137 | @override 138 | _i6.Future<_i11.Uint8List> readBytes(Uri? url, 139 | {Map? headers}) => 140 | (super.noSuchMethod( 141 | Invocation.method(#readBytes, [url], {#headers: headers}), 142 | returnValue: Future<_i11.Uint8List>.value(_i11.Uint8List(0))) 143 | as _i6.Future<_i11.Uint8List>); 144 | @override 145 | _i6.Future<_i4.StreamedResponse> send(_i4.BaseRequest? request) => 146 | (super.noSuchMethod(Invocation.method(#send, [request]), 147 | returnValue: 148 | Future<_i4.StreamedResponse>.value(_FakeStreamedResponse_3())) 149 | as _i6.Future<_i4.StreamedResponse>); 150 | @override 151 | void close() => super.noSuchMethod(Invocation.method(#close, []), 152 | returnValueForMissingStub: null); 153 | @override 154 | String toString() => super.toString(); 155 | } 156 | -------------------------------------------------------------------------------- /test/presentation/bloc/weather_bloc_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc_test/bloc_test.dart'; 2 | import 'package:dartz/dartz.dart'; 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:flutter_weather_app_sample/data/failure.dart'; 5 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 6 | import 'package:flutter_weather_app_sample/domain/usecases/get_current_weather.dart'; 7 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_bloc.dart'; 8 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_event.dart'; 9 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_state.dart'; 10 | import 'package:mockito/annotations.dart'; 11 | import 'package:mockito/mockito.dart'; 12 | 13 | import 'weather_bloc_test.mocks.dart'; 14 | 15 | @GenerateMocks([GetCurrentWeather]) 16 | void main() { 17 | late MockGetCurrentWeather mockGetCurrentWeather; 18 | late WeatherBloc weatherBloc; 19 | 20 | setUp(() { 21 | mockGetCurrentWeather = MockGetCurrentWeather(); 22 | weatherBloc = WeatherBloc(mockGetCurrentWeather); 23 | }); 24 | 25 | const tWeather = Weather( 26 | cityName: 'Jakarta', 27 | main: 'Clouds', 28 | description: 'few clouds', 29 | iconCode: '02d', 30 | temperature: 302.28, 31 | pressure: 1009, 32 | humidity: 70, 33 | ); 34 | 35 | const tCityName = 'Jakarta'; 36 | 37 | test( 38 | 'initial state should be empty', 39 | () { 40 | expect(weatherBloc.state, WeatherEmpty()); 41 | }, 42 | ); 43 | 44 | blocTest( 45 | 'should emit [loading, has data] when data is gotten successfully', 46 | build: () { 47 | when(mockGetCurrentWeather.execute(tCityName)) 48 | .thenAnswer((_) async => Right(tWeather)); 49 | return weatherBloc; 50 | }, 51 | act: (bloc) => bloc.add(OnCityChanged(tCityName)), 52 | wait: const Duration(milliseconds: 500), 53 | expect: () => [ 54 | WeatherLoading(), 55 | WeatherHasData(tWeather), 56 | ], 57 | verify: (bloc) { 58 | verify(mockGetCurrentWeather.execute(tCityName)); 59 | }, 60 | ); 61 | 62 | blocTest( 63 | 'should emit [loading, error] when get data is unsuccessful', 64 | build: () { 65 | when(mockGetCurrentWeather.execute(tCityName)) 66 | .thenAnswer((_) async => Left(ServerFailure('Server failure'))); 67 | return weatherBloc; 68 | }, 69 | act: (bloc) => bloc.add(OnCityChanged(tCityName)), 70 | wait: const Duration(milliseconds: 500), 71 | expect: () => [ 72 | WeatherLoading(), 73 | WeatherError('Server failure'), 74 | ], 75 | verify: (bloc) { 76 | verify(mockGetCurrentWeather.execute(tCityName)); 77 | }, 78 | ); 79 | } 80 | -------------------------------------------------------------------------------- /test/presentation/bloc/weather_bloc_test.mocks.dart: -------------------------------------------------------------------------------- 1 | // Mocks generated by Mockito 5.0.15 from annotations 2 | // in flutter_weather_app_sample/test/presentation/bloc/weather_bloc_test.dart. 3 | // Do not manually edit this file. 4 | 5 | import 'dart:async' as _i5; 6 | 7 | import 'package:dartz/dartz.dart' as _i3; 8 | import 'package:flutter_weather_app_sample/data/failure.dart' as _i6; 9 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart' as _i7; 10 | import 'package:flutter_weather_app_sample/domain/repositories/weather_repository.dart' 11 | as _i2; 12 | import 'package:flutter_weather_app_sample/domain/usecases/get_current_weather.dart' 13 | as _i4; 14 | import 'package:mockito/mockito.dart' as _i1; 15 | 16 | // ignore_for_file: avoid_redundant_argument_values 17 | // ignore_for_file: avoid_setters_without_getters 18 | // ignore_for_file: comment_references 19 | // ignore_for_file: implementation_imports 20 | // ignore_for_file: invalid_use_of_visible_for_testing_member 21 | // ignore_for_file: prefer_const_constructors 22 | // ignore_for_file: unnecessary_parenthesis 23 | 24 | class _FakeWeatherRepository_0 extends _i1.Fake 25 | implements _i2.WeatherRepository {} 26 | 27 | class _FakeEither_1 extends _i1.Fake implements _i3.Either {} 28 | 29 | /// A class which mocks [GetCurrentWeather]. 30 | /// 31 | /// See the documentation for Mockito's code generation for more information. 32 | class MockGetCurrentWeather extends _i1.Mock implements _i4.GetCurrentWeather { 33 | MockGetCurrentWeather() { 34 | _i1.throwOnMissingStub(this); 35 | } 36 | 37 | @override 38 | _i2.WeatherRepository get repository => 39 | (super.noSuchMethod(Invocation.getter(#repository), 40 | returnValue: _FakeWeatherRepository_0()) as _i2.WeatherRepository); 41 | @override 42 | _i5.Future<_i3.Either<_i6.Failure, _i7.Weather>> execute(String? cityName) => 43 | (super.noSuchMethod(Invocation.method(#execute, [cityName]), 44 | returnValue: Future<_i3.Either<_i6.Failure, _i7.Weather>>.value( 45 | _FakeEither_1<_i6.Failure, _i7.Weather>())) 46 | as _i5.Future<_i3.Either<_i6.Failure, _i7.Weather>>); 47 | @override 48 | String toString() => super.toString(); 49 | } 50 | -------------------------------------------------------------------------------- /test/presentation/pages/weather_page_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:bloc_test/bloc_test.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_bloc/flutter_bloc.dart'; 6 | import 'package:flutter_test/flutter_test.dart'; 7 | import 'package:flutter_weather_app_sample/data/constants.dart'; 8 | import 'package:flutter_weather_app_sample/domain/entities/weather.dart'; 9 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_bloc.dart'; 10 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_event.dart'; 11 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_state.dart'; 12 | import 'package:flutter_weather_app_sample/presentation/pages/weather_page.dart'; 13 | import 'package:get_it/get_it.dart'; 14 | import 'package:mocktail/mocktail.dart'; 15 | 16 | class MockWeatherBloc extends MockBloc 17 | implements WeatherBloc {} 18 | 19 | class FakeWeatherState extends Fake implements WeatherState {} 20 | 21 | class FakeWeatherEvent extends Fake implements WeatherEvent {} 22 | 23 | void main() { 24 | late MockWeatherBloc mockWeatherBloc; 25 | 26 | setUpAll(() async { 27 | HttpOverrides.global = null; 28 | registerFallbackValue(FakeWeatherState()); 29 | registerFallbackValue(FakeWeatherEvent()); 30 | 31 | final di = GetIt.instance; 32 | di.registerFactory(() => mockWeatherBloc); 33 | }); 34 | 35 | setUp(() { 36 | mockWeatherBloc = MockWeatherBloc(); 37 | }); 38 | 39 | const tWeather = Weather( 40 | cityName: 'Jakarta', 41 | main: 'Clouds', 42 | description: 'few clouds', 43 | iconCode: '02d', 44 | temperature: 302.28, 45 | pressure: 1009, 46 | humidity: 70, 47 | ); 48 | 49 | Widget _makeTestableWidget(Widget body) { 50 | return BlocProvider.value( 51 | value: mockWeatherBloc, 52 | child: MaterialApp( 53 | home: body, 54 | ), 55 | ); 56 | } 57 | 58 | testWidgets( 59 | 'text field should trigger state to change from empty to loading', 60 | (WidgetTester tester) async { 61 | // arrange 62 | when(() => mockWeatherBloc.state).thenReturn(WeatherEmpty()); 63 | 64 | // act 65 | await tester.pumpWidget(_makeTestableWidget(WeatherPage())); 66 | await tester.enterText(find.byType(TextField), 'Jakarta'); 67 | await tester.testTextInput.receiveAction(TextInputAction.done); 68 | await tester.pumpAndSettle(); 69 | 70 | // assert 71 | verify(() => mockWeatherBloc.add(OnCityChanged('Jakarta'))).called(1); 72 | expect(find.byType(TextField), equals(findsOneWidget)); 73 | }, 74 | ); 75 | 76 | testWidgets( 77 | 'should show progress indicator when state is loading', 78 | (WidgetTester tester) async { 79 | // arrange 80 | when(() => mockWeatherBloc.state).thenReturn(WeatherLoading()); 81 | 82 | // act 83 | await tester.pumpWidget(_makeTestableWidget(WeatherPage())); 84 | 85 | // assert 86 | expect(find.byType(CircularProgressIndicator), equals(findsOneWidget)); 87 | }, 88 | ); 89 | 90 | testWidgets( 91 | 'should show widget contain weather data when state is has data', 92 | (WidgetTester tester) async { 93 | // arrange 94 | when(() => mockWeatherBloc.state).thenReturn(WeatherHasData(tWeather)); 95 | 96 | // act 97 | await tester.pumpWidget(_makeTestableWidget(WeatherPage())); 98 | await tester.runAsync(() async { 99 | final HttpClient client = HttpClient(); 100 | await client.getUrl(Uri.parse(Urls.weatherIcon('02d'))); 101 | }); 102 | await tester.pumpAndSettle(); 103 | 104 | // assert 105 | expect(find.byKey(Key('weather_data')), equals(findsOneWidget)); 106 | }, 107 | ); 108 | } 109 | -------------------------------------------------------------------------------- /test/presentation/pages/weather_page_test.mocks.dart: -------------------------------------------------------------------------------- 1 | // Mocks generated by Mockito 5.0.15 from annotations 2 | // in flutter_weather_app_sample/test/presentation/pages/weather_page_test.dart. 3 | // Do not manually edit this file. 4 | 5 | import 'dart:async' as _i4; 6 | 7 | import 'package:flutter_bloc/flutter_bloc.dart' as _i6; 8 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_bloc.dart' 9 | as _i3; 10 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_event.dart' 11 | as _i5; 12 | import 'package:flutter_weather_app_sample/presentation/bloc/weather_state.dart' 13 | as _i2; 14 | import 'package:mockito/mockito.dart' as _i1; 15 | 16 | // ignore_for_file: avoid_redundant_argument_values 17 | // ignore_for_file: avoid_setters_without_getters 18 | // ignore_for_file: comment_references 19 | // ignore_for_file: implementation_imports 20 | // ignore_for_file: invalid_use_of_visible_for_testing_member 21 | // ignore_for_file: prefer_const_constructors 22 | // ignore_for_file: unnecessary_parenthesis 23 | 24 | class _FakeWeatherState_0 extends _i1.Fake implements _i2.WeatherState {} 25 | 26 | /// A class which mocks [WeatherBloc]. 27 | /// 28 | /// See the documentation for Mockito's code generation for more information. 29 | class MockWeatherBloc extends _i1.Mock implements _i3.WeatherBloc { 30 | MockWeatherBloc() { 31 | _i1.throwOnMissingStub(this); 32 | } 33 | 34 | @override 35 | _i2.WeatherState get state => (super.noSuchMethod(Invocation.getter(#state), 36 | returnValue: _FakeWeatherState_0()) as _i2.WeatherState); 37 | @override 38 | _i4.Stream<_i2.WeatherState> get stream => 39 | (super.noSuchMethod(Invocation.getter(#stream), 40 | returnValue: Stream<_i2.WeatherState>.empty()) 41 | as _i4.Stream<_i2.WeatherState>); 42 | @override 43 | bool get isClosed => 44 | (super.noSuchMethod(Invocation.getter(#isClosed), returnValue: false) 45 | as bool); 46 | @override 47 | void add(_i5.WeatherEvent? event) => 48 | super.noSuchMethod(Invocation.method(#add, [event]), 49 | returnValueForMissingStub: null); 50 | @override 51 | void onEvent(_i5.WeatherEvent? event) => 52 | super.noSuchMethod(Invocation.method(#onEvent, [event]), 53 | returnValueForMissingStub: null); 54 | @override 55 | void emit(_i2.WeatherState? state) => 56 | super.noSuchMethod(Invocation.method(#emit, [state]), 57 | returnValueForMissingStub: null); 58 | @override 59 | void on( 60 | _i6.EventHandler? handler, 61 | {_i6.EventTransformer? transformer}) => 62 | super.noSuchMethod( 63 | Invocation.method(#on, [handler], {#transformer: transformer}), 64 | returnValueForMissingStub: null); 65 | @override 66 | void onTransition( 67 | _i6.Transition<_i5.WeatherEvent, _i2.WeatherState>? transition) => 68 | super.noSuchMethod(Invocation.method(#onTransition, [transition]), 69 | returnValueForMissingStub: null); 70 | @override 71 | _i4.Future close() => (super.noSuchMethod(Invocation.method(#close, []), 72 | returnValue: Future.value(), 73 | returnValueForMissingStub: Future.value()) as _i4.Future); 74 | @override 75 | void onChange(_i6.Change<_i2.WeatherState>? change) => 76 | super.noSuchMethod(Invocation.method(#onChange, [change]), 77 | returnValueForMissingStub: null); 78 | @override 79 | void addError(Object? error, [StackTrace? stackTrace]) => 80 | super.noSuchMethod(Invocation.method(#addError, [error, stackTrace]), 81 | returnValueForMissingStub: null); 82 | @override 83 | void onError(Object? error, StackTrace? stackTrace) => 84 | super.noSuchMethod(Invocation.method(#onError, [error, stackTrace]), 85 | returnValueForMissingStub: null); 86 | @override 87 | String toString() => super.toString(); 88 | } 89 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestronaut/flutter-weather-app-sample/7c668dfb1b0ed9521267c2b5f94007ec3ec75750/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | flutter_weather_app_sample 27 | 28 | 29 | 30 | 33 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_weather_app_sample", 3 | "short_name": "flutter_weather_app_sample", 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 | } 24 | --------------------------------------------------------------------------------