├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── weather_clean_architecture_tdd │ │ │ │ └── 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 ├── 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 ├── core │ ├── constants │ │ └── constants.dart │ └── error │ │ ├── exception.dart │ │ └── failure.dart ├── data │ ├── data_sources │ │ └── remote_data_source.dart │ ├── models │ │ └── weather_model.dart │ └── repositories │ │ └── weather_repository_impl.dart ├── domain │ ├── entities │ │ └── weather.dart │ ├── repositories │ │ └── weather_repository.dart │ └── usecases │ │ └── get_current_weather.dart ├── injection_container.dart ├── main.dart └── presentation │ ├── bloc │ ├── weather_bloc.dart │ ├── weather_event.dart │ └── weather_state.dart │ └── pages │ └── weather_page.dart ├── pubspec.lock ├── pubspec.yaml ├── test ├── data │ ├── data_sources │ │ └── 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 │ └── pages │ └── weather_page_test.dart └── web ├── favicon.png ├── icons ├── Icon-192.png ├── Icon-512.png ├── Icon-maskable-192.png └── Icon-maskable-512.png ├── index.html └── manifest.json /.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: db747aa1331bd95bc9b3874c842261ca2d302cd5 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # weather_clean_architecture_tdd 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 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 46 | applicationId "com.example.weather_clean_architecture_tdd" 47 | minSdkVersion flutter.minSdkVersion 48 | targetSdkVersion flutter.targetSdkVersion 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/weather_clean_architecture_tdd/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.weather_clean_architecture_tdd 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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 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 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #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 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.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 = 50; 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 = 1300; 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 = ( 294 | "$(inherited)", 295 | "@executable_path/Frameworks", 296 | ); 297 | PRODUCT_BUNDLE_IDENTIFIER = com.example.weatherCleanArchitectureTdd; 298 | PRODUCT_NAME = "$(TARGET_NAME)"; 299 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 300 | SWIFT_VERSION = 5.0; 301 | VERSIONING_SYSTEM = "apple-generic"; 302 | }; 303 | name = Profile; 304 | }; 305 | 97C147031CF9000F007C117D /* Debug */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ALWAYS_SEARCH_USER_PATHS = NO; 309 | CLANG_ANALYZER_NONNULL = YES; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_COMMA = YES; 317 | CLANG_WARN_CONSTANT_CONVERSION = YES; 318 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 319 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 320 | CLANG_WARN_EMPTY_BODY = YES; 321 | CLANG_WARN_ENUM_CONVERSION = YES; 322 | CLANG_WARN_INFINITE_RECURSION = YES; 323 | CLANG_WARN_INT_CONVERSION = YES; 324 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 325 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 326 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 327 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 328 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 329 | CLANG_WARN_STRICT_PROTOTYPES = YES; 330 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 331 | CLANG_WARN_UNREACHABLE_CODE = YES; 332 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 333 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 334 | COPY_PHASE_STRIP = NO; 335 | DEBUG_INFORMATION_FORMAT = dwarf; 336 | ENABLE_STRICT_OBJC_MSGSEND = YES; 337 | ENABLE_TESTABILITY = YES; 338 | GCC_C_LANGUAGE_STANDARD = gnu99; 339 | GCC_DYNAMIC_NO_PIC = NO; 340 | GCC_NO_COMMON_BLOCKS = YES; 341 | GCC_OPTIMIZATION_LEVEL = 0; 342 | GCC_PREPROCESSOR_DEFINITIONS = ( 343 | "DEBUG=1", 344 | "$(inherited)", 345 | ); 346 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 347 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 348 | GCC_WARN_UNDECLARED_SELECTOR = YES; 349 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 350 | GCC_WARN_UNUSED_FUNCTION = YES; 351 | GCC_WARN_UNUSED_VARIABLE = YES; 352 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 353 | MTL_ENABLE_DEBUG_INFO = YES; 354 | ONLY_ACTIVE_ARCH = YES; 355 | SDKROOT = iphoneos; 356 | TARGETED_DEVICE_FAMILY = "1,2"; 357 | }; 358 | name = Debug; 359 | }; 360 | 97C147041CF9000F007C117D /* Release */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ALWAYS_SEARCH_USER_PATHS = NO; 364 | CLANG_ANALYZER_NONNULL = YES; 365 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 366 | CLANG_CXX_LIBRARY = "libc++"; 367 | CLANG_ENABLE_MODULES = YES; 368 | CLANG_ENABLE_OBJC_ARC = YES; 369 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 370 | CLANG_WARN_BOOL_CONVERSION = YES; 371 | CLANG_WARN_COMMA = YES; 372 | CLANG_WARN_CONSTANT_CONVERSION = YES; 373 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 374 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 375 | CLANG_WARN_EMPTY_BODY = YES; 376 | CLANG_WARN_ENUM_CONVERSION = YES; 377 | CLANG_WARN_INFINITE_RECURSION = YES; 378 | CLANG_WARN_INT_CONVERSION = YES; 379 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 380 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 381 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 384 | CLANG_WARN_STRICT_PROTOTYPES = YES; 385 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 386 | CLANG_WARN_UNREACHABLE_CODE = YES; 387 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 388 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 389 | COPY_PHASE_STRIP = NO; 390 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 391 | ENABLE_NS_ASSERTIONS = NO; 392 | ENABLE_STRICT_OBJC_MSGSEND = YES; 393 | GCC_C_LANGUAGE_STANDARD = gnu99; 394 | GCC_NO_COMMON_BLOCKS = YES; 395 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 396 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 397 | GCC_WARN_UNDECLARED_SELECTOR = YES; 398 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 399 | GCC_WARN_UNUSED_FUNCTION = YES; 400 | GCC_WARN_UNUSED_VARIABLE = YES; 401 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 402 | MTL_ENABLE_DEBUG_INFO = NO; 403 | SDKROOT = iphoneos; 404 | SUPPORTED_PLATFORMS = iphoneos; 405 | SWIFT_COMPILATION_MODE = wholemodule; 406 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 407 | TARGETED_DEVICE_FAMILY = "1,2"; 408 | VALIDATE_PRODUCT = YES; 409 | }; 410 | name = Release; 411 | }; 412 | 97C147061CF9000F007C117D /* Debug */ = { 413 | isa = XCBuildConfiguration; 414 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 415 | buildSettings = { 416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 417 | CLANG_ENABLE_MODULES = YES; 418 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 419 | ENABLE_BITCODE = NO; 420 | INFOPLIST_FILE = Runner/Info.plist; 421 | LD_RUNPATH_SEARCH_PATHS = ( 422 | "$(inherited)", 423 | "@executable_path/Frameworks", 424 | ); 425 | PRODUCT_BUNDLE_IDENTIFIER = com.example.weatherCleanArchitectureTdd; 426 | PRODUCT_NAME = "$(TARGET_NAME)"; 427 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 428 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 429 | SWIFT_VERSION = 5.0; 430 | VERSIONING_SYSTEM = "apple-generic"; 431 | }; 432 | name = Debug; 433 | }; 434 | 97C147071CF9000F007C117D /* Release */ = { 435 | isa = XCBuildConfiguration; 436 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 437 | buildSettings = { 438 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 439 | CLANG_ENABLE_MODULES = YES; 440 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 441 | ENABLE_BITCODE = NO; 442 | INFOPLIST_FILE = Runner/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = ( 444 | "$(inherited)", 445 | "@executable_path/Frameworks", 446 | ); 447 | PRODUCT_BUNDLE_IDENTIFIER = com.example.weatherCleanArchitectureTdd; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 450 | SWIFT_VERSION = 5.0; 451 | VERSIONING_SYSTEM = "apple-generic"; 452 | }; 453 | name = Release; 454 | }; 455 | /* End XCBuildConfiguration section */ 456 | 457 | /* Begin XCConfigurationList section */ 458 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 459 | isa = XCConfigurationList; 460 | buildConfigurations = ( 461 | 97C147031CF9000F007C117D /* Debug */, 462 | 97C147041CF9000F007C117D /* Release */, 463 | 249021D3217E4FDB00AE95B9 /* Profile */, 464 | ); 465 | defaultConfigurationIsVisible = 0; 466 | defaultConfigurationName = Release; 467 | }; 468 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 469 | isa = XCConfigurationList; 470 | buildConfigurations = ( 471 | 97C147061CF9000F007C117D /* Debug */, 472 | 97C147071CF9000F007C117D /* Release */, 473 | 249021D4217E4FDB00AE95B9 /* Profile */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | /* End XCConfigurationList section */ 479 | }; 480 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 481 | } 482 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/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/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Weather Clean Architecture Tdd 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | weather_clean_architecture_tdd 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/core/constants/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 | } -------------------------------------------------------------------------------- /lib/core/error/exception.dart: -------------------------------------------------------------------------------- 1 | class ServerException implements Exception {} -------------------------------------------------------------------------------- /lib/core/error/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 | } -------------------------------------------------------------------------------- /lib/data/data_sources/remote_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:weather_clean_architecture_tdd/core/error/exception.dart'; 3 | import 'package:weather_clean_architecture_tdd/data/models/weather_model.dart'; 4 | import 'package:http/http.dart' as http; 5 | import '../../core/constants/constants.dart'; 6 | 7 | abstract class WeatherRemoteDataSource { 8 | 9 | Future getCurrentWeather(String cityName); 10 | } 11 | 12 | 13 | class WeatherRemoteDataSourceImpl extends WeatherRemoteDataSource { 14 | final http.Client client; 15 | WeatherRemoteDataSourceImpl({required this.client}); 16 | 17 | @override 18 | Future < WeatherModel > getCurrentWeather(String cityName) async { 19 | final response = 20 | await client.get(Uri.parse(Urls.currentWeatherByName(cityName))); 21 | 22 | if (response.statusCode == 200) { 23 | return WeatherModel.fromJson(json.decode(response.body)); 24 | } else { 25 | throw ServerException(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /lib/data/models/weather_model.dart: -------------------------------------------------------------------------------- 1 | import '../../domain/entities/weather.dart'; 2 | 3 | class WeatherModel extends WeatherEntity { 4 | const WeatherModel({ 5 | required String cityName, 6 | required String main, 7 | required String description, 8 | required String iconCode, 9 | required double temperature, 10 | required int pressure, 11 | required int humidity, 12 | }): super( 13 | cityName: cityName, 14 | main: main, 15 | description: description, 16 | iconCode: iconCode, 17 | temperature: temperature, 18 | pressure: pressure, 19 | humidity: humidity 20 | ); 21 | 22 | factory WeatherModel.fromJson(Map < String, dynamic > json) => WeatherModel( 23 | cityName: json['name'], 24 | main: json['weather'][0]['main'], 25 | description: json['weather'][0]['description'], 26 | iconCode: json['weather'][0]['icon'], 27 | temperature: json['main']['temp'], 28 | pressure: json['main']['pressure'], 29 | humidity: json['main']['humidity'], 30 | ); 31 | 32 | Map < String, dynamic > toJson() => { 33 | 'weather': [{ 34 | 'main': main, 35 | 'description': description, 36 | 'icon': iconCode, 37 | }, ], 38 | 'main': { 39 | 'temp': temperature, 40 | 'pressure': pressure, 41 | 'humidity': humidity, 42 | }, 43 | 'name': cityName, 44 | }; 45 | 46 | WeatherEntity toEntity() => WeatherEntity( 47 | cityName: cityName, 48 | main: main, 49 | description: description, 50 | iconCode: iconCode, 51 | temperature: temperature, 52 | pressure: pressure, 53 | humidity: humidity, 54 | ); 55 | } -------------------------------------------------------------------------------- /lib/data/repositories/weather_repository_impl.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'dart:io'; 3 | 4 | import 'package:weather_clean_architecture_tdd/core/error/failure.dart'; 5 | import 'package:dartz/dartz.dart'; 6 | import 'package:weather_clean_architecture_tdd/data/data_sources/remote_data_source.dart'; 7 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 8 | import 'package:weather_clean_architecture_tdd/domain/repositories/weather_repository.dart'; 9 | 10 | import '../../core/error/exception.dart'; 11 | 12 | class WeatherRepositoryImpl extends WeatherRepository { 13 | 14 | final WeatherRemoteDataSource weatherRemoteDataSource; 15 | WeatherRepositoryImpl({required this.weatherRemoteDataSource}); 16 | 17 | @override 18 | Future < Either < Failure, WeatherEntity >> getCurrentWeather(String cityName) async { 19 | try { 20 | final result = await weatherRemoteDataSource.getCurrentWeather(cityName); 21 | return Right(result.toEntity()); 22 | } on ServerException { 23 | return const Left(ServerFailure('An error has occurred')); 24 | } on SocketException { 25 | return const Left(ConnectionFailure('Failed to connect to the network')); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/domain/entities/weather.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class WeatherEntity extends Equatable { 4 | 5 | const WeatherEntity({ 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 | @override 24 | List < Object ? > get props => [ 25 | cityName, 26 | main, 27 | description, 28 | iconCode, 29 | temperature, 30 | pressure, 31 | humidity, 32 | ]; 33 | } -------------------------------------------------------------------------------- /lib/domain/repositories/weather_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:weather_clean_architecture_tdd/core/error/failure.dart'; 3 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 4 | 5 | abstract class WeatherRepository { 6 | 7 | Future> getCurrentWeather(String cityName); 8 | } -------------------------------------------------------------------------------- /lib/domain/usecases/get_current_weather.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:weather_clean_architecture_tdd/core/error/failure.dart'; 3 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 4 | import 'package:weather_clean_architecture_tdd/domain/repositories/weather_repository.dart'; 5 | 6 | class GetCurrentWeatherUseCase { 7 | 8 | final WeatherRepository weatherRepository; 9 | 10 | GetCurrentWeatherUseCase(this.weatherRepository); 11 | 12 | Future> execute(String cityName) { 13 | return weatherRepository.getCurrentWeather(cityName); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/injection_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:get_it/get_it.dart'; 2 | import 'data/data_sources/remote_data_source.dart'; 3 | import 'data/repositories/weather_repository_impl.dart'; 4 | import 'domain/repositories/weather_repository.dart'; 5 | import 'domain/usecases/get_current_weather.dart'; 6 | import 'presentation/bloc/weather_bloc.dart'; 7 | import 'package:http/http.dart' as http; 8 | 9 | final locator = GetIt.instance; 10 | 11 | void setupLocator() { 12 | 13 | // bloc 14 | locator.registerFactory(() => WeatherBloc(locator())); 15 | 16 | // usecase 17 | locator.registerLazySingleton(() => GetCurrentWeatherUseCase(locator())); 18 | 19 | // repository 20 | locator.registerLazySingleton( 21 | () => WeatherRepositoryImpl( 22 | weatherRemoteDataSource: locator() 23 | ), 24 | ); 25 | 26 | // data source 27 | locator.registerLazySingleton( 28 | () => WeatherRemoteDataSourceImpl( 29 | client: locator(), 30 | ), 31 | ); 32 | 33 | // external 34 | locator.registerLazySingleton(() => http.Client()); 35 | 36 | 37 | 38 | } -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:weather_clean_architecture_tdd/injection_container.dart'; 4 | import 'package:weather_clean_architecture_tdd/presentation/pages/weather_page.dart'; 5 | 6 | import 'presentation/bloc/weather_bloc.dart'; 7 | 8 | void main() { 9 | setupLocator(); 10 | runApp(const MyApp()); 11 | } 12 | 13 | class MyApp extends StatelessWidget { 14 | const MyApp({Key? key}) : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return MultiBlocProvider( 19 | providers: [ 20 | BlocProvider( 21 | create: (_) => locator(), 22 | ) 23 | ], 24 | child: const MaterialApp( 25 | home: WeatherPage(), 26 | ), 27 | ); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /lib/presentation/bloc/weather_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_bloc/flutter_bloc.dart'; 2 | import 'package:weather_clean_architecture_tdd/domain/usecases/get_current_weather.dart'; 3 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_event.dart'; 4 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_state.dart'; 5 | import 'package:rxdart/rxdart.dart'; 6 | 7 | class WeatherBloc extends Bloc { 8 | 9 | final GetCurrentWeatherUseCase _getCurrentWeatherUseCase; 10 | WeatherBloc(this._getCurrentWeatherUseCase) : super(WeatherEmpty()) { 11 | on( 12 | (event, emit) async { 13 | 14 | emit(WeatherLoading()); 15 | final result = await _getCurrentWeatherUseCase.execute(event.cityName); 16 | result.fold( 17 | (failure) { 18 | emit(WeatherLoadFailue(failure.message)); 19 | }, 20 | (data) { 21 | emit(WeatherLoaded(data)); 22 | }, 23 | ); 24 | }, 25 | transformer: debounce(const Duration(milliseconds: 500)), 26 | ); 27 | } 28 | } 29 | 30 | EventTransformer debounce(Duration duration) { 31 | return (events, mapper) => events.debounceTime(duration).flatMap(mapper); 32 | } -------------------------------------------------------------------------------- /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 | const OnCityChanged(this.cityName); 14 | 15 | @override 16 | List get props => [cityName]; 17 | } -------------------------------------------------------------------------------- /lib/presentation/bloc/weather_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:weather_clean_architecture_tdd/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 WeatherLoaded extends WeatherState { 16 | final WeatherEntity result; 17 | 18 | const WeatherLoaded(this.result); 19 | 20 | @override 21 | List get props => [result]; 22 | } 23 | 24 | class WeatherLoadFailue extends WeatherState { 25 | final String message; 26 | 27 | const WeatherLoadFailue(this.message); 28 | 29 | @override 30 | List get props => [message]; 31 | } -------------------------------------------------------------------------------- /lib/presentation/pages/weather_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | 4 | import '../../core/constants/constants.dart'; 5 | import '../bloc/weather_bloc.dart'; 6 | import '../bloc/weather_event.dart'; 7 | import '../bloc/weather_state.dart'; 8 | 9 | class WeatherPage extends StatelessWidget { 10 | const WeatherPage({ Key? key }) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar( 16 | backgroundColor: const Color(0xff1D1E22), 17 | title: const Text( 18 | 'WEATHER', 19 | style: TextStyle(color: Colors.white), 20 | ), 21 | centerTitle: true, 22 | ), 23 | body: Padding( 24 | padding: const EdgeInsets.all(24.0), 25 | child: Column( 26 | mainAxisAlignment: MainAxisAlignment.center, 27 | children: [ 28 | TextField( 29 | textAlign: TextAlign.center, 30 | decoration: InputDecoration( 31 | hintText: 'Enter city name', 32 | fillColor: const Color(0xffF3F3F3), 33 | filled: true, 34 | focusedBorder: OutlineInputBorder( 35 | borderSide: BorderSide.none, 36 | borderRadius: BorderRadius.circular(10) 37 | ), 38 | enabledBorder: OutlineInputBorder( 39 | borderSide: BorderSide.none, 40 | borderRadius: BorderRadius.circular(10) 41 | ), 42 | ), 43 | onChanged: (query) { 44 | context.read().add(OnCityChanged(query)); 45 | }, 46 | ), 47 | const SizedBox(height: 32.0), 48 | BlocBuilder( 49 | builder: (context,state) { 50 | if (state is WeatherLoading) { 51 | return const Center( 52 | child: CircularProgressIndicator(), 53 | ); 54 | } 55 | if (state is WeatherLoaded) { 56 | return Column( 57 | key: const Key('weather_data'), 58 | children: [ 59 | Row( 60 | mainAxisAlignment: MainAxisAlignment.center, 61 | children: [ 62 | Text( 63 | state.result.cityName, 64 | style: const TextStyle( 65 | fontSize: 22.0, 66 | ), 67 | ), 68 | Image( 69 | image: NetworkImage( 70 | Urls.weatherIcon( 71 | state.result.iconCode, 72 | ), 73 | ), 74 | ), 75 | ], 76 | ), 77 | const SizedBox(height: 8.0), 78 | Text( 79 | '${state.result.main} | ${state.result.description}', 80 | style: const TextStyle( 81 | fontSize: 16.0, 82 | letterSpacing: 1.2, 83 | ), 84 | ), 85 | const SizedBox(height: 24.0), 86 | Table( 87 | defaultColumnWidth: const FixedColumnWidth(150.0), 88 | border: TableBorder.all( 89 | color: Colors.grey, 90 | style: BorderStyle.solid, 91 | width: 1, 92 | ), 93 | children: [ 94 | TableRow( 95 | children: [ 96 | const Padding( 97 | padding: EdgeInsets.all(8.0), 98 | child: Text( 99 | 'Temperature', 100 | style: TextStyle( 101 | fontSize: 16.0, 102 | letterSpacing: 1.2, 103 | ), 104 | ), 105 | ), 106 | Padding( 107 | padding: const EdgeInsets.all(8.0), 108 | child: Text( 109 | state.result.temperature.toString(), 110 | style: const TextStyle( 111 | fontSize: 16.0, 112 | letterSpacing: 1.2, 113 | fontWeight: FontWeight.bold, 114 | ), 115 | ), 116 | ), // Will be change later 117 | ] 118 | ), 119 | TableRow( 120 | children: [ 121 | const Padding( 122 | padding: EdgeInsets.all(8.0), 123 | child: Text( 124 | 'Pressure', 125 | style: TextStyle( 126 | fontSize: 16.0, 127 | letterSpacing: 1.2, 128 | ), 129 | ), 130 | ), 131 | Padding( 132 | padding: const EdgeInsets.all(8.0), 133 | child: Text( 134 | state.result.pressure.toString(), 135 | style: const TextStyle( 136 | fontSize: 16.0, 137 | letterSpacing: 1.2, 138 | fontWeight: FontWeight.bold 139 | ), 140 | ), 141 | ), // Will be change later 142 | ] 143 | ), 144 | TableRow( 145 | children: [ 146 | const Padding( 147 | padding: EdgeInsets.all(8.0), 148 | child: Text( 149 | 'Humidity', 150 | style: TextStyle( 151 | fontSize: 16.0, 152 | letterSpacing: 1.2, 153 | ), 154 | ), 155 | ), 156 | Padding( 157 | padding: const EdgeInsets.all(8.0), 158 | child: Text( 159 | state.result.humidity.toString(), 160 | style: const TextStyle( 161 | fontSize: 16.0, 162 | letterSpacing: 1.2, 163 | fontWeight: FontWeight.bold, 164 | ), 165 | ), 166 | ), // Will be change later 167 | ] 168 | ), 169 | ], 170 | ), 171 | ], 172 | ); 173 | } 174 | if (state is WeatherLoadFailue) { 175 | return Center( 176 | child: Text(state.message), 177 | ); 178 | } 179 | return Container(); 180 | }, 181 | ) 182 | ], 183 | ), 184 | ), 185 | ); 186 | } 187 | } -------------------------------------------------------------------------------- /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.flutter-io.cn" 9 | source: hosted 10 | version: "31.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.8.0" 18 | args: 19 | dependency: transitive 20 | description: 21 | name: args 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "2.3.1" 25 | async: 26 | dependency: transitive 27 | description: 28 | name: async 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "2.8.2" 32 | bloc: 33 | dependency: transitive 34 | description: 35 | name: bloc 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "8.1.2" 39 | bloc_test: 40 | dependency: "direct dev" 41 | description: 42 | name: bloc_test 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "9.1.3" 46 | boolean_selector: 47 | dependency: transitive 48 | description: 49 | name: boolean_selector 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "2.1.0" 53 | build: 54 | dependency: transitive 55 | description: 56 | name: build 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "2.3.0" 60 | build_config: 61 | dependency: transitive 62 | description: 63 | name: build_config 64 | url: "https://pub.flutter-io.cn" 65 | source: hosted 66 | version: "1.1.1" 67 | build_daemon: 68 | dependency: transitive 69 | description: 70 | name: build_daemon 71 | url: "https://pub.flutter-io.cn" 72 | source: hosted 73 | version: "3.1.1" 74 | build_resolvers: 75 | dependency: transitive 76 | description: 77 | name: build_resolvers 78 | url: "https://pub.flutter-io.cn" 79 | source: hosted 80 | version: "2.0.6" 81 | build_runner: 82 | dependency: "direct dev" 83 | description: 84 | name: build_runner 85 | url: "https://pub.flutter-io.cn" 86 | source: hosted 87 | version: "2.2.0" 88 | build_runner_core: 89 | dependency: transitive 90 | description: 91 | name: build_runner_core 92 | url: "https://pub.flutter-io.cn" 93 | source: hosted 94 | version: "7.2.3" 95 | built_collection: 96 | dependency: transitive 97 | description: 98 | name: built_collection 99 | url: "https://pub.flutter-io.cn" 100 | source: hosted 101 | version: "5.1.1" 102 | built_value: 103 | dependency: transitive 104 | description: 105 | name: built_value 106 | url: "https://pub.flutter-io.cn" 107 | source: hosted 108 | version: "8.6.1" 109 | characters: 110 | dependency: transitive 111 | description: 112 | name: characters 113 | url: "https://pub.flutter-io.cn" 114 | source: hosted 115 | version: "1.2.0" 116 | charcode: 117 | dependency: transitive 118 | description: 119 | name: charcode 120 | url: "https://pub.flutter-io.cn" 121 | source: hosted 122 | version: "1.3.1" 123 | checked_yaml: 124 | dependency: transitive 125 | description: 126 | name: checked_yaml 127 | url: "https://pub.flutter-io.cn" 128 | source: hosted 129 | version: "2.0.1" 130 | cli_util: 131 | dependency: transitive 132 | description: 133 | name: cli_util 134 | url: "https://pub.flutter-io.cn" 135 | source: hosted 136 | version: "0.3.5" 137 | clock: 138 | dependency: transitive 139 | description: 140 | name: clock 141 | url: "https://pub.flutter-io.cn" 142 | source: hosted 143 | version: "1.1.0" 144 | code_builder: 145 | dependency: transitive 146 | description: 147 | name: code_builder 148 | url: "https://pub.flutter-io.cn" 149 | source: hosted 150 | version: "4.1.0" 151 | collection: 152 | dependency: transitive 153 | description: 154 | name: collection 155 | url: "https://pub.flutter-io.cn" 156 | source: hosted 157 | version: "1.15.0" 158 | convert: 159 | dependency: transitive 160 | description: 161 | name: convert 162 | url: "https://pub.flutter-io.cn" 163 | source: hosted 164 | version: "3.1.0" 165 | coverage: 166 | dependency: transitive 167 | description: 168 | name: coverage 169 | url: "https://pub.flutter-io.cn" 170 | source: hosted 171 | version: "1.0.3" 172 | crypto: 173 | dependency: transitive 174 | description: 175 | name: crypto 176 | url: "https://pub.flutter-io.cn" 177 | source: hosted 178 | version: "3.0.2" 179 | cupertino_icons: 180 | dependency: "direct main" 181 | description: 182 | name: cupertino_icons 183 | url: "https://pub.flutter-io.cn" 184 | source: hosted 185 | version: "1.0.5" 186 | dart_style: 187 | dependency: transitive 188 | description: 189 | name: dart_style 190 | url: "https://pub.flutter-io.cn" 191 | source: hosted 192 | version: "2.2.1" 193 | dartz: 194 | dependency: "direct main" 195 | description: 196 | name: dartz 197 | url: "https://pub.flutter-io.cn" 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.flutter-io.cn" 205 | source: hosted 206 | version: "0.4.1" 207 | equatable: 208 | dependency: "direct main" 209 | description: 210 | name: equatable 211 | url: "https://pub.flutter-io.cn" 212 | source: hosted 213 | version: "2.0.5" 214 | fake_async: 215 | dependency: transitive 216 | description: 217 | name: fake_async 218 | url: "https://pub.flutter-io.cn" 219 | source: hosted 220 | version: "1.2.0" 221 | file: 222 | dependency: transitive 223 | description: 224 | name: file 225 | url: "https://pub.flutter-io.cn" 226 | source: hosted 227 | version: "6.1.4" 228 | fixnum: 229 | dependency: transitive 230 | description: 231 | name: fixnum 232 | url: "https://pub.flutter-io.cn" 233 | source: hosted 234 | version: "1.0.1" 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.flutter-io.cn" 245 | source: hosted 246 | version: "8.1.3" 247 | flutter_lints: 248 | dependency: "direct dev" 249 | description: 250 | name: flutter_lints 251 | url: "https://pub.flutter-io.cn" 252 | source: hosted 253 | version: "1.0.4" 254 | flutter_test: 255 | dependency: "direct dev" 256 | description: flutter 257 | source: sdk 258 | version: "0.0.0" 259 | frontend_server_client: 260 | dependency: transitive 261 | description: 262 | name: frontend_server_client 263 | url: "https://pub.flutter-io.cn" 264 | source: hosted 265 | version: "2.1.3" 266 | get_it: 267 | dependency: "direct main" 268 | description: 269 | name: get_it 270 | url: "https://pub.flutter-io.cn" 271 | source: hosted 272 | version: "7.6.0" 273 | glob: 274 | dependency: transitive 275 | description: 276 | name: glob 277 | url: "https://pub.flutter-io.cn" 278 | source: hosted 279 | version: "2.1.1" 280 | graphs: 281 | dependency: transitive 282 | description: 283 | name: graphs 284 | url: "https://pub.flutter-io.cn" 285 | source: hosted 286 | version: "2.2.0" 287 | http: 288 | dependency: "direct main" 289 | description: 290 | name: http 291 | url: "https://pub.flutter-io.cn" 292 | source: hosted 293 | version: "0.13.5" 294 | http_multi_server: 295 | dependency: transitive 296 | description: 297 | name: http_multi_server 298 | url: "https://pub.flutter-io.cn" 299 | source: hosted 300 | version: "3.2.1" 301 | http_parser: 302 | dependency: transitive 303 | description: 304 | name: http_parser 305 | url: "https://pub.flutter-io.cn" 306 | source: hosted 307 | version: "4.0.2" 308 | io: 309 | dependency: transitive 310 | description: 311 | name: io 312 | url: "https://pub.flutter-io.cn" 313 | source: hosted 314 | version: "1.0.4" 315 | js: 316 | dependency: transitive 317 | description: 318 | name: js 319 | url: "https://pub.flutter-io.cn" 320 | source: hosted 321 | version: "0.6.5" 322 | json_annotation: 323 | dependency: transitive 324 | description: 325 | name: json_annotation 326 | url: "https://pub.flutter-io.cn" 327 | source: hosted 328 | version: "4.6.0" 329 | lints: 330 | dependency: transitive 331 | description: 332 | name: lints 333 | url: "https://pub.flutter-io.cn" 334 | source: hosted 335 | version: "1.0.1" 336 | logging: 337 | dependency: transitive 338 | description: 339 | name: logging 340 | url: "https://pub.flutter-io.cn" 341 | source: hosted 342 | version: "1.1.0" 343 | matcher: 344 | dependency: transitive 345 | description: 346 | name: matcher 347 | url: "https://pub.flutter-io.cn" 348 | source: hosted 349 | version: "0.12.11" 350 | material_color_utilities: 351 | dependency: transitive 352 | description: 353 | name: material_color_utilities 354 | url: "https://pub.flutter-io.cn" 355 | source: hosted 356 | version: "0.1.3" 357 | meta: 358 | dependency: transitive 359 | description: 360 | name: meta 361 | url: "https://pub.flutter-io.cn" 362 | source: hosted 363 | version: "1.7.0" 364 | mime: 365 | dependency: transitive 366 | description: 367 | name: mime 368 | url: "https://pub.flutter-io.cn" 369 | source: hosted 370 | version: "1.0.3" 371 | mockito: 372 | dependency: "direct dev" 373 | description: 374 | name: mockito 375 | url: "https://pub.flutter-io.cn" 376 | source: hosted 377 | version: "5.2.0" 378 | mocktail: 379 | dependency: "direct dev" 380 | description: 381 | name: mocktail 382 | url: "https://pub.flutter-io.cn" 383 | source: hosted 384 | version: "0.2.0" 385 | nested: 386 | dependency: transitive 387 | description: 388 | name: nested 389 | url: "https://pub.flutter-io.cn" 390 | source: hosted 391 | version: "1.0.0" 392 | node_preamble: 393 | dependency: transitive 394 | description: 395 | name: node_preamble 396 | url: "https://pub.flutter-io.cn" 397 | source: hosted 398 | version: "2.0.2" 399 | package_config: 400 | dependency: transitive 401 | description: 402 | name: package_config 403 | url: "https://pub.flutter-io.cn" 404 | source: hosted 405 | version: "2.1.0" 406 | path: 407 | dependency: transitive 408 | description: 409 | name: path 410 | url: "https://pub.flutter-io.cn" 411 | source: hosted 412 | version: "1.8.0" 413 | pool: 414 | dependency: transitive 415 | description: 416 | name: pool 417 | url: "https://pub.flutter-io.cn" 418 | source: hosted 419 | version: "1.5.1" 420 | provider: 421 | dependency: transitive 422 | description: 423 | name: provider 424 | url: "https://pub.flutter-io.cn" 425 | source: hosted 426 | version: "6.0.5" 427 | pub_semver: 428 | dependency: transitive 429 | description: 430 | name: pub_semver 431 | url: "https://pub.flutter-io.cn" 432 | source: hosted 433 | version: "2.1.2" 434 | pubspec_parse: 435 | dependency: transitive 436 | description: 437 | name: pubspec_parse 438 | url: "https://pub.flutter-io.cn" 439 | source: hosted 440 | version: "1.2.1" 441 | rxdart: 442 | dependency: "direct main" 443 | description: 444 | name: rxdart 445 | url: "https://pub.flutter-io.cn" 446 | source: hosted 447 | version: "0.27.7" 448 | shelf: 449 | dependency: transitive 450 | description: 451 | name: shelf 452 | url: "https://pub.flutter-io.cn" 453 | source: hosted 454 | version: "1.3.2" 455 | shelf_packages_handler: 456 | dependency: transitive 457 | description: 458 | name: shelf_packages_handler 459 | url: "https://pub.flutter-io.cn" 460 | source: hosted 461 | version: "3.0.1" 462 | shelf_static: 463 | dependency: transitive 464 | description: 465 | name: shelf_static 466 | url: "https://pub.flutter-io.cn" 467 | source: hosted 468 | version: "1.1.1" 469 | shelf_web_socket: 470 | dependency: transitive 471 | description: 472 | name: shelf_web_socket 473 | url: "https://pub.flutter-io.cn" 474 | source: hosted 475 | version: "1.0.2" 476 | sky_engine: 477 | dependency: transitive 478 | description: flutter 479 | source: sdk 480 | version: "0.0.99" 481 | source_gen: 482 | dependency: transitive 483 | description: 484 | name: source_gen 485 | url: "https://pub.flutter-io.cn" 486 | source: hosted 487 | version: "1.2.2" 488 | source_map_stack_trace: 489 | dependency: transitive 490 | description: 491 | name: source_map_stack_trace 492 | url: "https://pub.flutter-io.cn" 493 | source: hosted 494 | version: "2.1.1" 495 | source_maps: 496 | dependency: transitive 497 | description: 498 | name: source_maps 499 | url: "https://pub.flutter-io.cn" 500 | source: hosted 501 | version: "0.10.10" 502 | source_span: 503 | dependency: transitive 504 | description: 505 | name: source_span 506 | url: "https://pub.flutter-io.cn" 507 | source: hosted 508 | version: "1.8.1" 509 | stack_trace: 510 | dependency: transitive 511 | description: 512 | name: stack_trace 513 | url: "https://pub.flutter-io.cn" 514 | source: hosted 515 | version: "1.10.0" 516 | stream_channel: 517 | dependency: transitive 518 | description: 519 | name: stream_channel 520 | url: "https://pub.flutter-io.cn" 521 | source: hosted 522 | version: "2.1.0" 523 | stream_transform: 524 | dependency: transitive 525 | description: 526 | name: stream_transform 527 | url: "https://pub.flutter-io.cn" 528 | source: hosted 529 | version: "2.1.0" 530 | string_scanner: 531 | dependency: transitive 532 | description: 533 | name: string_scanner 534 | url: "https://pub.flutter-io.cn" 535 | source: hosted 536 | version: "1.1.0" 537 | term_glyph: 538 | dependency: transitive 539 | description: 540 | name: term_glyph 541 | url: "https://pub.flutter-io.cn" 542 | source: hosted 543 | version: "1.2.0" 544 | test: 545 | dependency: transitive 546 | description: 547 | name: test 548 | url: "https://pub.flutter-io.cn" 549 | source: hosted 550 | version: "1.19.5" 551 | test_api: 552 | dependency: transitive 553 | description: 554 | name: test_api 555 | url: "https://pub.flutter-io.cn" 556 | source: hosted 557 | version: "0.4.8" 558 | test_core: 559 | dependency: transitive 560 | description: 561 | name: test_core 562 | url: "https://pub.flutter-io.cn" 563 | source: hosted 564 | version: "0.4.9" 565 | timing: 566 | dependency: transitive 567 | description: 568 | name: timing 569 | url: "https://pub.flutter-io.cn" 570 | source: hosted 571 | version: "1.0.1" 572 | typed_data: 573 | dependency: transitive 574 | description: 575 | name: typed_data 576 | url: "https://pub.flutter-io.cn" 577 | source: hosted 578 | version: "1.3.0" 579 | vector_math: 580 | dependency: transitive 581 | description: 582 | name: vector_math 583 | url: "https://pub.flutter-io.cn" 584 | source: hosted 585 | version: "2.1.1" 586 | vm_service: 587 | dependency: transitive 588 | description: 589 | name: vm_service 590 | url: "https://pub.flutter-io.cn" 591 | source: hosted 592 | version: "7.5.0" 593 | watcher: 594 | dependency: transitive 595 | description: 596 | name: watcher 597 | url: "https://pub.flutter-io.cn" 598 | source: hosted 599 | version: "1.0.2" 600 | web_socket_channel: 601 | dependency: transitive 602 | description: 603 | name: web_socket_channel 604 | url: "https://pub.flutter-io.cn" 605 | source: hosted 606 | version: "2.4.0" 607 | webkit_inspection_protocol: 608 | dependency: transitive 609 | description: 610 | name: webkit_inspection_protocol 611 | url: "https://pub.flutter-io.cn" 612 | source: hosted 613 | version: "1.2.0" 614 | yaml: 615 | dependency: transitive 616 | description: 617 | name: yaml 618 | url: "https://pub.flutter-io.cn" 619 | source: hosted 620 | version: "3.1.1" 621 | sdks: 622 | dart: ">=2.16.1 <3.0.0" 623 | flutter: ">=1.16.0" 624 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: weather_clean_architecture_tdd 2 | description: A new Flutter project. 3 | 4 | publish_to: 'none' 5 | 6 | version: 1.0.0+1 7 | 8 | environment: 9 | sdk: ">=2.16.1 <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 | dev_dependencies: 24 | bloc_test: ^9.0.2 25 | build_runner: ^2.1.2 26 | flutter_test: 27 | sdk: flutter 28 | mockito: ^5.0.15 29 | mocktail: ^0.2.0 30 | flutter_lints: ^1.0.0 31 | 32 | flutter: 33 | 34 | uses-material-design: true 35 | 36 | -------------------------------------------------------------------------------- /test/data/data_sources/remote_data_source_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:mockito/mockito.dart'; 3 | import 'package:weather_clean_architecture_tdd/core/constants/constants.dart'; 4 | import 'package:weather_clean_architecture_tdd/core/error/exception.dart'; 5 | import 'package:weather_clean_architecture_tdd/data/data_sources/remote_data_source.dart'; 6 | import 'package:http/http.dart' as http; 7 | import 'package:weather_clean_architecture_tdd/data/models/weather_model.dart'; 8 | import '../../helpers/json_reader.dart'; 9 | import '../../helpers/test_helper.mocks.dart'; 10 | 11 | void main() { 12 | 13 | late MockHttpClient mockHttpClient; 14 | late WeatherRemoteDataSourceImpl weatherRemoteDataSourceImpl; 15 | 16 | setUp(() { 17 | mockHttpClient = MockHttpClient(); 18 | weatherRemoteDataSourceImpl = WeatherRemoteDataSourceImpl(client: mockHttpClient); 19 | }); 20 | 21 | const testCityName = 'New York'; 22 | 23 | group('get current weather', () { 24 | 25 | test('should return weather model when the response code is 200', () async { 26 | 27 | //arrange 28 | when( 29 | mockHttpClient.get( 30 | Uri.parse(Urls.currentWeatherByName(testCityName)) 31 | ) 32 | ).thenAnswer( 33 | (_) async => http.Response( 34 | readJson('helpers/dummy_data/dummy_weather_response.json'), 35 | 200 36 | ) 37 | ); 38 | 39 | //act 40 | final result = await weatherRemoteDataSourceImpl.getCurrentWeather(testCityName); 41 | 42 | //assert 43 | expect(result, isA()); 44 | 45 | }); 46 | 47 | 48 | test( 49 | 'should throw a server exception when the response code is 404 or other', 50 | () async { 51 | //arrange 52 | when( 53 | mockHttpClient.get( Uri.parse(Urls.currentWeatherByName(testCityName))), 54 | ).thenAnswer( 55 | (_) async => http.Response('Not found',404) 56 | ); 57 | 58 | //act 59 | final result = weatherRemoteDataSourceImpl.getCurrentWeather(testCityName); 60 | 61 | //assert 62 | expect(result, throwsA(isA())); 63 | 64 | }, 65 | ); 66 | 67 | 68 | }); 69 | } -------------------------------------------------------------------------------- /test/data/models/weather_model_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:weather_clean_architecture_tdd/data/models/weather_model.dart'; 5 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 6 | 7 | import '../../helpers/json_reader.dart'; 8 | 9 | void main() { 10 | 11 | const testWeatherModel = WeatherModel( 12 | cityName: 'New York', 13 | main: 'Clear', 14 | description: 'clear sky', 15 | iconCode: '01n', 16 | temperature: 292.87, 17 | pressure: 1012, 18 | humidity: 70, 19 | ); 20 | 21 | test( 22 | 'should be a subclass of weather entity', 23 | () async { 24 | 25 | //assert 26 | expect(testWeatherModel, isA < WeatherEntity > ()); 27 | } 28 | ); 29 | 30 | 31 | test( 32 | 'should return a valid model from json', 33 | () async { 34 | 35 | //arrange 36 | final Map < String, dynamic > jsonMap = json.decode( 37 | readJson('helpers/dummy_data/dummy_weather_response.json'), 38 | ); 39 | 40 | //act 41 | final result = WeatherModel.fromJson(jsonMap); 42 | 43 | //assert 44 | expect(result, equals(testWeatherModel)); 45 | 46 | } 47 | ); 48 | 49 | 50 | test( 51 | 'should return a json map containing proper data', 52 | () async { 53 | 54 | // act 55 | final result = testWeatherModel.toJson(); 56 | 57 | // assert 58 | final expectedJsonMap = { 59 | 'weather': [{ 60 | 'main': 'Clear', 61 | 'description': 'clear sky', 62 | 'icon': '01n', 63 | }], 64 | 'main': { 65 | 'temp': 292.87, 66 | 'pressure': 1012, 67 | 'humidity': 70, 68 | }, 69 | 'name': 'New York', 70 | }; 71 | 72 | expect(result, equals(expectedJsonMap)); 73 | 74 | }, 75 | ); 76 | 77 | } -------------------------------------------------------------------------------- /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:mockito/mockito.dart'; 6 | import 'package:weather_clean_architecture_tdd/core/error/exception.dart'; 7 | import 'package:weather_clean_architecture_tdd/core/error/failure.dart'; 8 | import 'package:weather_clean_architecture_tdd/data/models/weather_model.dart'; 9 | import 'package:weather_clean_architecture_tdd/data/repositories/weather_repository_impl.dart'; 10 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 11 | 12 | import '../../helpers/test_helper.mocks.dart'; 13 | 14 | void main() { 15 | 16 | late MockWeatherRemoteDataSource mockWeatherRemoteDataSource; 17 | late WeatherRepositoryImpl weatherRepositoryImpl; 18 | 19 | setUp(() { 20 | mockWeatherRemoteDataSource = MockWeatherRemoteDataSource(); 21 | weatherRepositoryImpl = WeatherRepositoryImpl( 22 | weatherRemoteDataSource: mockWeatherRemoteDataSource, 23 | ); 24 | }); 25 | 26 | const testWeatherModel = WeatherModel( 27 | cityName: 'New York', 28 | main: 'Clouds', 29 | description: 'few clouds', 30 | iconCode: '02d', 31 | temperature: 302.28, 32 | pressure: 1009, 33 | humidity: 70, 34 | ); 35 | 36 | const testWeatherEntity = WeatherEntity( 37 | cityName: 'New York', 38 | main: 'Clouds', 39 | description: 'few clouds', 40 | iconCode: '02d', 41 | temperature: 302.28, 42 | pressure: 1009, 43 | humidity: 70, 44 | ); 45 | 46 | const testCityName = 'New York'; 47 | 48 | 49 | group('get current weather', () { 50 | 51 | test( 52 | 'should return current weather when a call to data source is successful', 53 | () async { 54 | // arrange 55 | when(mockWeatherRemoteDataSource.getCurrentWeather(testCityName)) 56 | .thenAnswer((_) async => testWeatherModel); 57 | 58 | // act 59 | final result = await weatherRepositoryImpl.getCurrentWeather(testCityName); 60 | 61 | // assert 62 | expect(result, equals(const Right(testWeatherEntity))); 63 | }, 64 | ); 65 | 66 | test( 67 | 'should return server failure when a call to data source is unsuccessful', 68 | () async { 69 | // arrange 70 | when(mockWeatherRemoteDataSource.getCurrentWeather(testCityName)) 71 | .thenThrow(ServerException()); 72 | 73 | // act 74 | final result = await weatherRepositoryImpl.getCurrentWeather(testCityName); 75 | 76 | // assert 77 | expect(result, equals(const Left(ServerFailure('An error has occurred')))); 78 | }, 79 | ); 80 | 81 | test( 82 | 'should return connection failure when the device has no internet', 83 | () async { 84 | // arrange 85 | when(mockWeatherRemoteDataSource.getCurrentWeather(testCityName)) 86 | .thenThrow(const SocketException('Failed to connect to the network')); 87 | 88 | // act 89 | final result = await weatherRepositoryImpl.getCurrentWeather(testCityName); 90 | 91 | // assert 92 | expect(result, equals(const Left(ConnectionFailure('Failed to connect to the network')))); 93 | }, 94 | ); 95 | 96 | }); 97 | 98 | 99 | } -------------------------------------------------------------------------------- /test/domain/usecases/get_current_weather_test.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:dartz/dartz.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:mockito/mockito.dart'; 6 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 7 | import 'package:weather_clean_architecture_tdd/domain/usecases/get_current_weather.dart'; 8 | 9 | import '../../helpers/test_helper.mocks.dart'; 10 | 11 | void main() { 12 | 13 | late GetCurrentWeatherUseCase getCurrentWeatherUseCase; 14 | late MockWeatherRepository mockWeatherRepository; 15 | 16 | setUp((){ 17 | mockWeatherRepository = MockWeatherRepository(); 18 | getCurrentWeatherUseCase = GetCurrentWeatherUseCase(mockWeatherRepository); 19 | }); 20 | 21 | const testWeatherDetail = WeatherEntity( 22 | cityName: 'New York', 23 | main: 'Clouds', 24 | description: 'few clouds', 25 | iconCode: '02d', 26 | temperature: 302.28, 27 | pressure: 1009, 28 | humidity: 70, 29 | ); 30 | 31 | const testCityName = 'New York'; 32 | 33 | test( 34 | 'should get current weather detail from the repository', 35 | () async { 36 | // arrange 37 | when( 38 | mockWeatherRepository.getCurrentWeather(testCityName) 39 | ).thenAnswer((_) async => const Right(testWeatherDetail) ); 40 | 41 | // act 42 | final result = await getCurrentWeatherUseCase.execute(testCityName); 43 | 44 | // assert 45 | expect(result, const Right(testWeatherDetail)); 46 | 47 | } 48 | ); 49 | } -------------------------------------------------------------------------------- /test/helpers/dummy_data/dummy_weather_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "coord": { 3 | "lon": -74.006, 4 | "lat": 40.7143 5 | }, 6 | "weather": [{ 7 | "id": 800, 8 | "main": "Clear", 9 | "description": "clear sky", 10 | "icon": "01n" 11 | }], 12 | "base": "stations", 13 | "main": { 14 | "temp": 292.87, 15 | "feels_like": 292.73, 16 | "temp_min": 290.47, 17 | "temp_max": 294.25, 18 | "pressure": 1012, 19 | "humidity": 70 20 | }, 21 | "visibility": 10000, 22 | "wind": { 23 | "speed": 6.26, 24 | "deg": 319, 25 | "gust": 8.94 26 | }, 27 | "clouds": { 28 | "all": 0 29 | }, 30 | "dt": 1690708177, 31 | "sys": { 32 | "type": 2, 33 | "id": 2008101, 34 | "country": "US", 35 | "sunrise": 1690710627, 36 | "sunset": 1690762457 37 | }, 38 | "timezone": -14400, 39 | "id": 5128581, 40 | "name": "New York", 41 | "cod": 200 42 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /test/helpers/test_helper.dart: -------------------------------------------------------------------------------- 1 | import 'package:mockito/annotations.dart'; 2 | import 'package:weather_clean_architecture_tdd/data/data_sources/remote_data_source.dart'; 3 | import 'package:weather_clean_architecture_tdd/domain/repositories/weather_repository.dart'; 4 | import 'package:http/http.dart' as http; 5 | import 'package:weather_clean_architecture_tdd/domain/usecases/get_current_weather.dart'; 6 | 7 | 8 | @GenerateMocks( 9 | [ 10 | WeatherRepository, 11 | WeatherRemoteDataSource, 12 | GetCurrentWeatherUseCase 13 | ], 14 | customMocks: [MockSpec(as: #MockHttpClient)], 15 | ) 16 | 17 | void main() {} -------------------------------------------------------------------------------- /test/helpers/test_helper.mocks.dart: -------------------------------------------------------------------------------- 1 | // Mocks generated by Mockito 5.2.0 from annotations 2 | // in weather_clean_architecture_tdd/test/helpers/test_helper.dart. 3 | // Do not manually edit this file. 4 | 5 | import 'dart:async' as _i6; 6 | import 'dart:convert' as _i11; 7 | import 'dart:typed_data' as _i12; 8 | 9 | import 'package:dartz/dartz.dart' as _i2; 10 | import 'package:http/http.dart' as _i5; 11 | import 'package:mockito/mockito.dart' as _i1; 12 | import 'package:weather_clean_architecture_tdd/core/error/failure.dart' as _i7; 13 | import 'package:weather_clean_architecture_tdd/data/data_sources/remote_data_source.dart' 14 | as _i9; 15 | import 'package:weather_clean_architecture_tdd/data/models/weather_model.dart' 16 | as _i3; 17 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart' 18 | as _i8; 19 | import 'package:weather_clean_architecture_tdd/domain/repositories/weather_repository.dart' 20 | as _i4; 21 | import 'package:weather_clean_architecture_tdd/domain/usecases/get_current_weather.dart' 22 | as _i10; 23 | 24 | // ignore_for_file: type=lint 25 | // ignore_for_file: avoid_redundant_argument_values 26 | // ignore_for_file: avoid_setters_without_getters 27 | // ignore_for_file: comment_references 28 | // ignore_for_file: implementation_imports 29 | // ignore_for_file: invalid_use_of_visible_for_testing_member 30 | // ignore_for_file: prefer_const_constructors 31 | // ignore_for_file: unnecessary_parenthesis 32 | // ignore_for_file: camel_case_types 33 | 34 | class _FakeEither_0 extends _i1.Fake implements _i2.Either {} 35 | 36 | class _FakeWeatherModel_1 extends _i1.Fake implements _i3.WeatherModel {} 37 | 38 | class _FakeWeatherRepository_2 extends _i1.Fake 39 | implements _i4.WeatherRepository {} 40 | 41 | class _FakeResponse_3 extends _i1.Fake implements _i5.Response {} 42 | 43 | class _FakeStreamedResponse_4 extends _i1.Fake implements _i5.StreamedResponse { 44 | } 45 | 46 | /// A class which mocks [WeatherRepository]. 47 | /// 48 | /// See the documentation for Mockito's code generation for more information. 49 | class MockWeatherRepository extends _i1.Mock implements _i4.WeatherRepository { 50 | MockWeatherRepository() { 51 | _i1.throwOnMissingStub(this); 52 | } 53 | 54 | @override 55 | _i6.Future<_i2.Either<_i7.Failure, _i8.WeatherEntity>> getCurrentWeather( 56 | String? cityName) => 57 | (super.noSuchMethod(Invocation.method(#getCurrentWeather, [cityName]), 58 | returnValue: Future<_i2.Either<_i7.Failure, _i8.WeatherEntity>>.value( 59 | _FakeEither_0<_i7.Failure, _i8.WeatherEntity>())) as _i6 60 | .Future<_i2.Either<_i7.Failure, _i8.WeatherEntity>>); 61 | } 62 | 63 | /// A class which mocks [WeatherRemoteDataSource]. 64 | /// 65 | /// See the documentation for Mockito's code generation for more information. 66 | class MockWeatherRemoteDataSource extends _i1.Mock 67 | implements _i9.WeatherRemoteDataSource { 68 | MockWeatherRemoteDataSource() { 69 | _i1.throwOnMissingStub(this); 70 | } 71 | 72 | @override 73 | _i6.Future<_i3.WeatherModel> getCurrentWeather(String? cityName) => 74 | (super.noSuchMethod(Invocation.method(#getCurrentWeather, [cityName]), 75 | returnValue: 76 | Future<_i3.WeatherModel>.value(_FakeWeatherModel_1())) 77 | as _i6.Future<_i3.WeatherModel>); 78 | } 79 | 80 | /// A class which mocks [GetCurrentWeatherUseCase]. 81 | /// 82 | /// See the documentation for Mockito's code generation for more information. 83 | class MockGetCurrentWeatherUseCase extends _i1.Mock 84 | implements _i10.GetCurrentWeatherUseCase { 85 | MockGetCurrentWeatherUseCase() { 86 | _i1.throwOnMissingStub(this); 87 | } 88 | 89 | @override 90 | _i4.WeatherRepository get weatherRepository => 91 | (super.noSuchMethod(Invocation.getter(#weatherRepository), 92 | returnValue: _FakeWeatherRepository_2()) as _i4.WeatherRepository); 93 | @override 94 | _i6.Future<_i2.Either<_i7.Failure, _i8.WeatherEntity>> execute( 95 | String? cityName) => 96 | (super.noSuchMethod(Invocation.method(#execute, [cityName]), 97 | returnValue: Future<_i2.Either<_i7.Failure, _i8.WeatherEntity>>.value( 98 | _FakeEither_0<_i7.Failure, _i8.WeatherEntity>())) as _i6 99 | .Future<_i2.Either<_i7.Failure, _i8.WeatherEntity>>); 100 | } 101 | 102 | /// A class which mocks [Client]. 103 | /// 104 | /// See the documentation for Mockito's code generation for more information. 105 | class MockHttpClient extends _i1.Mock implements _i5.Client { 106 | MockHttpClient() { 107 | _i1.throwOnMissingStub(this); 108 | } 109 | 110 | @override 111 | _i6.Future<_i5.Response> head(Uri? url, {Map? headers}) => 112 | (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}), 113 | returnValue: Future<_i5.Response>.value(_FakeResponse_3())) 114 | as _i6.Future<_i5.Response>); 115 | @override 116 | _i6.Future<_i5.Response> get(Uri? url, {Map? headers}) => 117 | (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), 118 | returnValue: Future<_i5.Response>.value(_FakeResponse_3())) 119 | as _i6.Future<_i5.Response>); 120 | @override 121 | _i6.Future<_i5.Response> post(Uri? url, 122 | {Map? headers, 123 | Object? body, 124 | _i11.Encoding? encoding}) => 125 | (super.noSuchMethod( 126 | Invocation.method(#post, [url], 127 | {#headers: headers, #body: body, #encoding: encoding}), 128 | returnValue: Future<_i5.Response>.value(_FakeResponse_3())) 129 | as _i6.Future<_i5.Response>); 130 | @override 131 | _i6.Future<_i5.Response> put(Uri? url, 132 | {Map? headers, 133 | Object? body, 134 | _i11.Encoding? encoding}) => 135 | (super.noSuchMethod( 136 | Invocation.method(#put, [url], 137 | {#headers: headers, #body: body, #encoding: encoding}), 138 | returnValue: Future<_i5.Response>.value(_FakeResponse_3())) 139 | as _i6.Future<_i5.Response>); 140 | @override 141 | _i6.Future<_i5.Response> patch(Uri? url, 142 | {Map? headers, 143 | Object? body, 144 | _i11.Encoding? encoding}) => 145 | (super.noSuchMethod( 146 | Invocation.method(#patch, [url], 147 | {#headers: headers, #body: body, #encoding: encoding}), 148 | returnValue: Future<_i5.Response>.value(_FakeResponse_3())) 149 | as _i6.Future<_i5.Response>); 150 | @override 151 | _i6.Future<_i5.Response> delete(Uri? url, 152 | {Map? headers, 153 | Object? body, 154 | _i11.Encoding? encoding}) => 155 | (super.noSuchMethod( 156 | Invocation.method(#delete, [url], 157 | {#headers: headers, #body: body, #encoding: encoding}), 158 | returnValue: Future<_i5.Response>.value(_FakeResponse_3())) 159 | as _i6.Future<_i5.Response>); 160 | @override 161 | _i6.Future read(Uri? url, {Map? headers}) => 162 | (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}), 163 | returnValue: Future.value('')) as _i6.Future); 164 | @override 165 | _i6.Future<_i12.Uint8List> readBytes(Uri? url, 166 | {Map? headers}) => 167 | (super.noSuchMethod( 168 | Invocation.method(#readBytes, [url], {#headers: headers}), 169 | returnValue: Future<_i12.Uint8List>.value(_i12.Uint8List(0))) 170 | as _i6.Future<_i12.Uint8List>); 171 | @override 172 | _i6.Future<_i5.StreamedResponse> send(_i5.BaseRequest? request) => 173 | (super.noSuchMethod(Invocation.method(#send, [request]), 174 | returnValue: 175 | Future<_i5.StreamedResponse>.value(_FakeStreamedResponse_4())) 176 | as _i6.Future<_i5.StreamedResponse>); 177 | @override 178 | void close() => super.noSuchMethod(Invocation.method(#close, []), 179 | returnValueForMissingStub: null); 180 | } 181 | -------------------------------------------------------------------------------- /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:mockito/mockito.dart'; 5 | import 'package:weather_clean_architecture_tdd/core/error/failure.dart'; 6 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 7 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_bloc.dart'; 8 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_event.dart'; 9 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_state.dart'; 10 | 11 | import '../../helpers/test_helper.mocks.dart'; 12 | 13 | void main() { 14 | 15 | late MockGetCurrentWeatherUseCase mockGetCurrentWeatherUseCase; 16 | late WeatherBloc weatherBloc; 17 | 18 | setUp(() { 19 | mockGetCurrentWeatherUseCase = MockGetCurrentWeatherUseCase(); 20 | weatherBloc = WeatherBloc(mockGetCurrentWeatherUseCase); 21 | }); 22 | 23 | const testWeather = WeatherEntity( 24 | cityName: 'New York', 25 | main: 'Clouds', 26 | description: 'few clouds', 27 | iconCode: '02d', 28 | temperature: 302.28, 29 | pressure: 1009, 30 | humidity: 70, 31 | ); 32 | 33 | const testCityName = 'New York'; 34 | 35 | test( 36 | 'initial state should be empty', 37 | () { 38 | expect(weatherBloc.state, WeatherEmpty()); 39 | } 40 | ); 41 | 42 | 43 | blocTest( 44 | 'should emit [WeatherLoading, WeatherLoaded] when data is gotten successfully', 45 | build: () { 46 | when( 47 | mockGetCurrentWeatherUseCase.execute(testCityName) 48 | ).thenAnswer((_) async => const Right(testWeather)); 49 | return weatherBloc; 50 | }, 51 | act: (bloc) => bloc.add(const OnCityChanged(testCityName)), 52 | wait: const Duration(milliseconds: 500), 53 | expect: () => [ 54 | WeatherLoading(), 55 | const WeatherLoaded(testWeather) 56 | ] 57 | ); 58 | 59 | 60 | blocTest( 61 | 'should emit [WeatherLoading, WeatherLoadFailure] when get data is unsuccessful', 62 | build: () { 63 | when( 64 | mockGetCurrentWeatherUseCase.execute(testCityName) 65 | ).thenAnswer((_) async => const Left(ServerFailure('Server failure'))); 66 | return weatherBloc; 67 | }, 68 | act: (bloc) => bloc.add(const OnCityChanged(testCityName)), 69 | wait: const Duration(milliseconds: 500), 70 | expect: () => [ 71 | WeatherLoading(), 72 | const WeatherLoadFailue('Server failure'), 73 | ] 74 | ); 75 | 76 | 77 | } -------------------------------------------------------------------------------- /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:mocktail/mocktail.dart'; 8 | import 'package:weather_clean_architecture_tdd/domain/entities/weather.dart'; 9 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_bloc.dart'; 10 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_event.dart'; 11 | import 'package:weather_clean_architecture_tdd/presentation/bloc/weather_state.dart'; 12 | import 'package:weather_clean_architecture_tdd/presentation/pages/weather_page.dart'; 13 | 14 | class MockWeatherBloc extends MockBloc implements WeatherBloc { } 15 | 16 | void main() { 17 | 18 | late MockWeatherBloc mockWeatherBloc; 19 | 20 | setUp((){ 21 | mockWeatherBloc = MockWeatherBloc(); 22 | HttpOverrides.global = null; 23 | }); 24 | 25 | 26 | Widget _makeTestableWidget(Widget body) { 27 | return BlocProvider( 28 | create: (context) => mockWeatherBloc, 29 | child: MaterialApp( 30 | home: body, 31 | ), 32 | ); 33 | } 34 | 35 | const testWeather = WeatherEntity( 36 | cityName: 'New York', 37 | main: 'Clouds', 38 | description: 'few clouds', 39 | iconCode: '02d', 40 | temperature: 302.28, 41 | pressure: 1009, 42 | humidity: 70, 43 | ); 44 | 45 | 46 | testWidgets( 47 | 'text field should trigger state to change from empty to loading', 48 | (widgetTester) async { 49 | //arrange 50 | when(()=> mockWeatherBloc.state).thenReturn(WeatherEmpty()); 51 | 52 | //act 53 | await widgetTester.pumpWidget(_makeTestableWidget(const WeatherPage())); 54 | var textField = find.byType(TextField); 55 | expect(textField, findsOneWidget); 56 | await widgetTester.enterText(textField, 'New York'); 57 | await widgetTester.pump(); 58 | expect(find.text('New York'),findsOneWidget); 59 | }, 60 | ); 61 | 62 | 63 | testWidgets( 64 | 'should show progress indicator when state is loading', 65 | (widgetTester) async { 66 | //arrange 67 | when(()=> mockWeatherBloc.state).thenReturn(WeatherLoading()); 68 | 69 | //act 70 | await widgetTester.pumpWidget(_makeTestableWidget(const WeatherPage())); 71 | 72 | //assert 73 | expect(find.byType(CircularProgressIndicator), findsOneWidget); 74 | }, 75 | ); 76 | 77 | 78 | testWidgets( 79 | 'should show widget contain weather data when state is weather loaded', 80 | (widgetTester) async { 81 | //arrange 82 | when(()=> mockWeatherBloc.state).thenReturn(const WeatherLoaded(testWeather)); 83 | 84 | //act 85 | await widgetTester.pumpWidget(_makeTestableWidget(const WeatherPage())); 86 | 87 | //assert 88 | expect(find.byKey(const Key('weather_data')), findsOneWidget); 89 | }, 90 | ); 91 | 92 | 93 | 94 | 95 | } -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdinazmi/Flutter-Clean-Architecture-TDD-Weather-App/417aa0d8da6d2587fd6bb91a2959d8c03e533772/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | weather_clean_architecture_tdd 33 | 34 | 35 | 36 | 39 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weather_clean_architecture_tdd", 3 | "short_name": "weather_clean_architecture_tdd", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | --------------------------------------------------------------------------------