├── .cirrus.yml ├── .gitignore ├── .metadata ├── README.md ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── clean_architecture │ │ │ │ └── with_bloc │ │ │ │ └── MainActivity.java │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── decrypt.sh ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── fonts ├── Roboto-Bold.ttf └── Roboto-Regular.ttf ├── images └── logo.png ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ └── contents.xcworkspacedata └── 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 │ ├── error │ │ ├── exceptions.dart │ │ └── failures.dart │ ├── network │ │ ├── network_info.dart │ │ ├── rest_client_service.chopper.dart │ │ └── rest_client_service.dart │ ├── usecases │ │ ├── fetch_token.dart │ │ └── usecase.dart │ ├── utils │ │ ├── constants.dart │ │ ├── router.dart │ │ └── theme.dart │ └── widgets │ │ └── custom_snak_bar.dart ├── injection_container.dart ├── main.dart └── screens │ ├── change_password │ ├── data │ │ ├── datasources │ │ │ ├── change_password_local_datasource.dart │ │ │ └── change_password_remote_datasource.dart │ │ └── repositories │ │ │ └── change_password_repository_impl.dart │ ├── domain │ │ ├── repositories │ │ │ └── change_password_repository.dart │ │ └── usecases │ │ │ └── change_password.dart │ └── presentation │ │ ├── blocs │ │ └── change_password │ │ │ ├── bloc.dart │ │ │ ├── change_password_bloc.dart │ │ │ ├── change_password_event.dart │ │ │ └── change_password_state.dart │ │ └── page │ │ └── change_password.dart │ ├── home │ ├── data │ │ ├── datasources │ │ │ ├── home_local_datasource.dart │ │ │ └── home_remote_datasource.dart │ │ └── repositories │ │ │ └── home_repository_impl.dart │ ├── domain │ │ ├── repositories │ │ │ └── home_repository.dart │ │ └── usecases │ │ │ └── logout_user.dart │ └── presentation │ │ ├── blocs │ │ └── log_out │ │ │ ├── bloc.dart │ │ │ ├── log_out_bloc.dart │ │ │ ├── log_out_event.dart │ │ │ └── log_out_state.dart │ │ └── page │ │ └── home.dart │ └── login │ ├── data │ ├── datasources │ │ ├── login_local_datasource.dart │ │ └── login_remote_datasource.dart │ ├── models │ │ ├── login_model.dart │ │ └── login_model.g.dart │ └── repositories │ │ └── login_repository_impl.dart │ ├── domain │ ├── entities │ │ └── login.dart │ ├── repositories │ │ └── login_repository.dart │ └── usecases │ │ └── login_user.dart │ └── presentation │ ├── blocs │ └── user_login │ │ ├── bloc.dart │ │ ├── user_login_bloc.dart │ │ ├── user_login_event.dart │ │ └── user_login_state.dart │ └── page │ └── login.dart ├── pubspec.lock ├── pubspec.yaml ├── test ├── core │ ├── network │ │ └── network_info_test.dart │ └── usecases │ │ └── fetch_token_test.dart ├── fixtures │ ├── fixture_reader.dart │ ├── user_login.json │ └── user_login_null_token.json └── screens │ ├── change_password │ ├── data │ │ ├── datasources │ │ │ └── change_password_remote_datasource_test.dart │ │ └── repositories │ │ │ └── change_password_repository_impl_test.dart │ ├── domain │ │ └── usecases │ │ │ └── change_password_test.dart │ └── presentation │ │ ├── blocs │ │ └── change_password │ │ │ └── change_password_bloc_test.dart │ │ └── page │ │ └── change_password_test.dart │ ├── home │ ├── data │ │ ├── datasources │ │ │ ├── home_local_datasource_test.dart │ │ │ └── home_remote_datasource_test.dart │ │ └── repositories │ │ │ └── home_repository_impl_test.dart │ ├── domain │ │ └── usecases │ │ │ └── logout_user_test.dart │ └── presentation │ │ └── blocs │ │ └── log_out │ │ └── log_out_bloc_test.dart │ └── login │ ├── data │ ├── datasources │ │ ├── login_local_datasource_test.dart │ │ └── login_remote_datasource_test.dart │ ├── models │ │ └── login_model_test.dart │ └── repositories │ │ └── login_repository_impl_test.dart │ ├── domain │ └── usecases │ │ └── login_user_test.dart │ └── presentation │ └── blocs │ └── user_login │ └── user_login_bloc_test.dart ├── test_driver ├── app.dart └── app_test.dart └── upload_artifacts.sh /.cirrus.yml: -------------------------------------------------------------------------------- 1 | container: 2 | image: cirrusci/flutter:v1.12.13-hotfix.6 3 | environment: 4 | KEY_STORE: ENCRYPTED[b23f28befb3714c5d3f37e04f419f091e50a3bf12ae678f39f97677439fbc4f4fd70aa7d0beccbb3a701361c0d6c79bc] 5 | GITHUB_TOKEN: ENCRYPTED[ef4f655063e815cc18aeab46a6a69e10dd68a3c2359b3291685679493895aadfc7e19b2385aac20925316aa4bf28942a] 6 | 7 | style_check_task: 8 | only_if: $CIRRUS_BRANCH == "master" || $CIRRUS_PR != "" 9 | pub_cache: 10 | folder: ~/.pub-cache 11 | int_script: 12 | - flutter doctor 13 | - flutter pub get 14 | - dartanalyzer . 15 | 16 | debug_buid_task: 17 | only_if: $CIRRUS_BRANCH == "master" || $CIRRUS_PR != "" 18 | pub_cache: 19 | folder: ~/.pub-cache 20 | int_script: 21 | - flutter doctor 22 | - flutter pub get 23 | - dartanalyzer . 24 | build_dev_release_script: 25 | - flutter build apk 26 | always: 27 | upload_artifacts: 28 | path: "build/app/outputs/apk/release/*.apk" 29 | 30 | release_buid_task: 31 | only_if: $CIRRUS_RELEASE != "" 32 | pub_cache: 33 | folder: ~/.pub-cache 34 | int_script: 35 | - flutter doctor 36 | - flutter pub get 37 | - dartanalyzer . 38 | decrypt_dev_release_credentials_script: 39 | - bash android/decrypt.sh 40 | build_dev_release_script: 41 | - flutter build apk --split-per-abi 42 | - flutter build appbundle || true 43 | always: 44 | upload_artifacts: 45 | path: "build/app/outputs/apk/release/*.apk" 46 | upload_to_github_script: 47 | - bash upload_artifacts.sh -------------------------------------------------------------------------------- /.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 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Exceptions to above rules. 37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 38 | -------------------------------------------------------------------------------- /.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: 27321ebbad34b0a3fafe99fac037102196d655ff 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter clean architecture sample 2 | 3 | - Clean architecture with SOLID principals 4 | - Developed under test driven development 5 | - Blocs has been used for state management 6 | - Includes unit tests, widget tests, integration tests and CI/CD 7 | 8 | # File Structure 9 | 10 | ```bash 11 | lib 12 | ├── core 13 | │   ├── error 14 | │   │   ├── exceptions.dart 15 | │   │   └── failures.dart 16 | │   ├── network 17 | │   │   ├── network_info.dart 18 | │   │   ├── rest_client_service.chopper.dart 19 | │   │   └── rest_client_service.dart 20 | │   ├── usecases 21 | │   │   ├── fetch_token.dart 22 | │   │   └── usecase.dart 23 | │   ├── utils 24 | │   │   ├── constants.dart 25 | │   │   ├── router.dart 26 | │   │   └── theme.dart 27 | │   └── widgets 28 | │   └── custom_snak_bar.dart 29 | ├── injection_container.dart 30 | ├── main.dart 31 | └── screens 32 | ├── change_password 33 | │   ├── data 34 | │   │   ├── datasources 35 | │   │   │   ├── change_password_local_datasource.dart 36 | │   │   │   └── change_password_remote_datasource.dart 37 | │   │   └── repositories 38 | │   │   └── change_password_repository_impl.dart 39 | │   ├── domain 40 | │   │   ├── repositories 41 | │   │   │   └── change_password_repository.dart 42 | │   │   └── usecases 43 | │   │   └── change_password.dart 44 | │   └── presentation 45 | │   ├── blocs 46 | │   │   └── change_password 47 | │   │   ├── bloc.dart 48 | │   │   ├── change_password_bloc.dart 49 | │   │   ├── change_password_event.dart 50 | │   │   └── change_password_state.dart 51 | │   └── page 52 | │   └── change_password.dart 53 | ├── home 54 | │   ├── data 55 | │   │   ├── datasources 56 | │   │   │   ├── home_local_datasource.dart 57 | │   │   │   └── home_remote_datasource.dart 58 | │   │   └── repositories 59 | │   │   └── home_repository_impl.dart 60 | │   ├── domain 61 | │   │   ├── repositories 62 | │   │   │   └── home_repository.dart 63 | │   │   └── usecases 64 | │   │   └── logout_user.dart 65 | │   └── presentation 66 | │   ├── blocs 67 | │   │   └── log_out 68 | │   │   ├── bloc.dart 69 | │   │   ├── log_out_bloc.dart 70 | │   │   ├── log_out_event.dart 71 | │   │   └── log_out_state.dart 72 | │   └── page 73 | │   └── home.dart 74 | └── login 75 | ├── data 76 | │   ├── datasources 77 | │   │   ├── login_local_datasource.dart 78 | │   │   └── login_remote_datasource.dart 79 | │   ├── models 80 | │   │   ├── login_model.dart 81 | │   │   └── login_model.g.dart 82 | │   └── repositories 83 | │   └── login_repository_impl.dart 84 | ├── domain 85 | │   ├── entities 86 | │   │   └── login.dart 87 | │   ├── repositories 88 | │   │   └── login_repository.dart 89 | │   └── usecases 90 | │   └── login_user.dart 91 | └── presentation 92 | ├── blocs 93 | │   └── user_login 94 | │   ├── bloc.dart 95 | │   ├── user_login_bloc.dart 96 | │   ├── user_login_event.dart 97 | │   └── user_login_state.dart 98 | └── page 99 | └── login.dart 100 | ``` 101 | 102 | 103 | # File structure for tests 104 | 105 | ```bash 106 | test 107 | ├── core 108 | │   ├── network 109 | │   │   └── network_info_test.dart 110 | │   └── usecases 111 | │   └── fetch_token_test.dart 112 | ├── fixtures 113 | │   ├── fixture_reader.dart 114 | │   ├── user_login.json 115 | │   └── user_login_null_token.json 116 | └── screens 117 | ├── change_password 118 | │   ├── data 119 | │   │   ├── datasources 120 | │   │   │   └── change_password_remote_datasource_test.dart 121 | │   │   └── repositories 122 | │   │   └── change_password_repository_impl_test.dart 123 | │   ├── domain 124 | │   │   └── usecases 125 | │   │   └── change_password_test.dart 126 | │   └── presentation 127 | │   └── blocs 128 | │   └── change_password 129 | │   └── change_password_bloc_test.dart 130 | ├── home 131 | │   ├── data 132 | │   │   ├── datasources 133 | │   │   │   ├── home_local_datasource_test.dart 134 | │   │   │   └── home_remote_datasource_test.dart 135 | │   │   └── repositories 136 | │   │   └── home_repository_impl_test.dart 137 | │   ├── domain 138 | │   │   └── usecases 139 | │   │   └── logout_user_test.dart 140 | │   └── presentation 141 | │   └── blocs 142 | │   └── log_out 143 | │   └── log_out_bloc_test.dart 144 | └── login 145 | ├── data 146 | │   ├── datasources 147 | │   │   ├── login_local_datasource_test.dart 148 | │   │   └── login_remote_datasource_test.dart 149 | │   ├── models 150 | │   │   └── login_model_test.dart 151 | │   └── repositories 152 | │   └── login_repository_impl_test.dart 153 | ├── domain 154 | │   └── usecases 155 | │   └── login_user_test.dart 156 | └── presentation 157 | └── blocs 158 | └── user_login 159 | └── user_login_bloc_test.dart 160 | ``` -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "clean_architecture.with_bloc" 37 | minSdkVersion 16 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | testImplementation 'junit:junit:4.12' 59 | androidTestImplementation 'androidx.test:runner:1.1.1' 60 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 61 | } 62 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 9 | 10 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /android/app/src/main/java/clean_architecture/with_bloc/MainActivity.java: -------------------------------------------------------------------------------- 1 | package clean_architecture.with_bloc; 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity; 5 | import io.flutter.embedding.engine.FlutterEngine; 6 | import io.flutter.plugins.GeneratedPluginRegistrant; 7 | 8 | public class MainActivity extends FlutterActivity { 9 | @Override 10 | public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { 11 | GeneratedPluginRegistrant.registerWith(flutterEngine); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.5.0' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /android/decrypt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Decrypt Files 4 | rm android/key.jks || true 5 | rm android/key.properties || true 6 | gpg --quiet --batch --yes --decrypt --passphrase="$KEY_STORE" --output android/key.jks android/key.jks.gpg 7 | gpg --quiet --batch --yes --decrypt --passphrase="$KEY_STORE" --output android/key.properties android/key.properties.gpg 8 | echo storeFile=`pwd`/android/key.jks >> android/key.properties 9 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /fonts/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/fonts/Roboto-Bold.ttf -------------------------------------------------------------------------------- /fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/images/logo.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 18 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 19 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXCopyFilesBuildPhase section */ 23 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 24 | isa = PBXCopyFilesBuildPhase; 25 | buildActionMask = 2147483647; 26 | dstPath = ""; 27 | dstSubfolderSpec = 10; 28 | files = ( 29 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 30 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 31 | ); 32 | name = "Embed Frameworks"; 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXCopyFilesBuildPhase section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 39 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 40 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 41 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 42 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 43 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 44 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 45 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 46 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 47 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 48 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | /* End PBXFileReference section */ 54 | 55 | /* Begin PBXFrameworksBuildPhase section */ 56 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 61 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | 9740EEB11CF90186004384FC /* Flutter */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 3B80C3931E831B6300D905FE /* App.framework */, 72 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 73 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 74 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 75 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 76 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 77 | ); 78 | name = Flutter; 79 | sourceTree = ""; 80 | }; 81 | 97C146E51CF9000F007C117D = { 82 | isa = PBXGroup; 83 | children = ( 84 | 9740EEB11CF90186004384FC /* Flutter */, 85 | 97C146F01CF9000F007C117D /* Runner */, 86 | 97C146EF1CF9000F007C117D /* Products */, 87 | ); 88 | sourceTree = ""; 89 | }; 90 | 97C146EF1CF9000F007C117D /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 97C146EE1CF9000F007C117D /* Runner.app */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | 97C146F01CF9000F007C117D /* Runner */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 102 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 103 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 104 | 97C147021CF9000F007C117D /* Info.plist */, 105 | 97C146F11CF9000F007C117D /* Supporting Files */, 106 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 107 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 108 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 109 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 110 | ); 111 | path = Runner; 112 | sourceTree = ""; 113 | }; 114 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | ); 118 | name = "Supporting Files"; 119 | sourceTree = ""; 120 | }; 121 | /* End PBXGroup section */ 122 | 123 | /* Begin PBXNativeTarget section */ 124 | 97C146ED1CF9000F007C117D /* Runner */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 127 | buildPhases = ( 128 | 9740EEB61CF901F6004384FC /* Run Script */, 129 | 97C146EA1CF9000F007C117D /* Sources */, 130 | 97C146EB1CF9000F007C117D /* Frameworks */, 131 | 97C146EC1CF9000F007C117D /* Resources */, 132 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 133 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = Runner; 140 | productName = Runner; 141 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 142 | productType = "com.apple.product-type.application"; 143 | }; 144 | /* End PBXNativeTarget section */ 145 | 146 | /* Begin PBXProject section */ 147 | 97C146E61CF9000F007C117D /* Project object */ = { 148 | isa = PBXProject; 149 | attributes = { 150 | LastUpgradeCheck = 1020; 151 | ORGANIZATIONNAME = "The Chromium Authors"; 152 | TargetAttributes = { 153 | 97C146ED1CF9000F007C117D = { 154 | CreatedOnToolsVersion = 7.3.1; 155 | LastSwiftMigration = 1100; 156 | }; 157 | }; 158 | }; 159 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 160 | compatibilityVersion = "Xcode 3.2"; 161 | developmentRegion = en; 162 | hasScannedForEncodings = 0; 163 | knownRegions = ( 164 | en, 165 | Base, 166 | ); 167 | mainGroup = 97C146E51CF9000F007C117D; 168 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 169 | projectDirPath = ""; 170 | projectRoot = ""; 171 | targets = ( 172 | 97C146ED1CF9000F007C117D /* Runner */, 173 | ); 174 | }; 175 | /* End PBXProject section */ 176 | 177 | /* Begin PBXResourcesBuildPhase section */ 178 | 97C146EC1CF9000F007C117D /* Resources */ = { 179 | isa = PBXResourcesBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 183 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 184 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 185 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXResourcesBuildPhase section */ 190 | 191 | /* Begin PBXShellScriptBuildPhase section */ 192 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 193 | isa = PBXShellScriptBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | ); 197 | inputPaths = ( 198 | ); 199 | name = "Thin Binary"; 200 | outputPaths = ( 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | shellPath = /bin/sh; 204 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 205 | }; 206 | 9740EEB61CF901F6004384FC /* Run Script */ = { 207 | isa = PBXShellScriptBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | ); 211 | inputPaths = ( 212 | ); 213 | name = "Run Script"; 214 | outputPaths = ( 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | shellPath = /bin/sh; 218 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 219 | }; 220 | /* End PBXShellScriptBuildPhase section */ 221 | 222 | /* Begin PBXSourcesBuildPhase section */ 223 | 97C146EA1CF9000F007C117D /* Sources */ = { 224 | isa = PBXSourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 228 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXVariantGroup section */ 235 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 236 | isa = PBXVariantGroup; 237 | children = ( 238 | 97C146FB1CF9000F007C117D /* Base */, 239 | ); 240 | name = Main.storyboard; 241 | sourceTree = ""; 242 | }; 243 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | 97C147001CF9000F007C117D /* Base */, 247 | ); 248 | name = LaunchScreen.storyboard; 249 | sourceTree = ""; 250 | }; 251 | /* End PBXVariantGroup section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 255 | isa = XCBuildConfiguration; 256 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 257 | buildSettings = { 258 | ALWAYS_SEARCH_USER_PATHS = NO; 259 | CLANG_ANALYZER_NONNULL = YES; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 261 | CLANG_CXX_LIBRARY = "libc++"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_COMMA = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 270 | CLANG_WARN_EMPTY_BODY = YES; 271 | CLANG_WARN_ENUM_CONVERSION = YES; 272 | CLANG_WARN_INFINITE_RECURSION = YES; 273 | CLANG_WARN_INT_CONVERSION = YES; 274 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 275 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 276 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 278 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 279 | CLANG_WARN_STRICT_PROTOTYPES = YES; 280 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 284 | COPY_PHASE_STRIP = NO; 285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 286 | ENABLE_NS_ASSERTIONS = NO; 287 | ENABLE_STRICT_OBJC_MSGSEND = YES; 288 | GCC_C_LANGUAGE_STANDARD = gnu99; 289 | GCC_NO_COMMON_BLOCKS = YES; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 297 | MTL_ENABLE_DEBUG_INFO = NO; 298 | SDKROOT = iphoneos; 299 | SUPPORTED_PLATFORMS = iphoneos; 300 | TARGETED_DEVICE_FAMILY = "1,2"; 301 | VALIDATE_PRODUCT = YES; 302 | }; 303 | name = Profile; 304 | }; 305 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 306 | isa = XCBuildConfiguration; 307 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 308 | buildSettings = { 309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 310 | CLANG_ENABLE_MODULES = YES; 311 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 312 | ENABLE_BITCODE = NO; 313 | FRAMEWORK_SEARCH_PATHS = ( 314 | "$(inherited)", 315 | "$(PROJECT_DIR)/Flutter", 316 | ); 317 | INFOPLIST_FILE = Runner/Info.plist; 318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 319 | LIBRARY_SEARCH_PATHS = ( 320 | "$(inherited)", 321 | "$(PROJECT_DIR)/Flutter", 322 | ); 323 | PRODUCT_BUNDLE_IDENTIFIER = clean_architecture.with_bloc; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 326 | SWIFT_VERSION = 5.0; 327 | VERSIONING_SYSTEM = "apple-generic"; 328 | }; 329 | name = Profile; 330 | }; 331 | 97C147031CF9000F007C117D /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 334 | buildSettings = { 335 | ALWAYS_SEARCH_USER_PATHS = NO; 336 | CLANG_ANALYZER_NONNULL = YES; 337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 338 | CLANG_CXX_LIBRARY = "libc++"; 339 | CLANG_ENABLE_MODULES = YES; 340 | CLANG_ENABLE_OBJC_ARC = YES; 341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 342 | CLANG_WARN_BOOL_CONVERSION = YES; 343 | CLANG_WARN_COMMA = YES; 344 | CLANG_WARN_CONSTANT_CONVERSION = YES; 345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 347 | CLANG_WARN_EMPTY_BODY = YES; 348 | CLANG_WARN_ENUM_CONVERSION = YES; 349 | CLANG_WARN_INFINITE_RECURSION = YES; 350 | CLANG_WARN_INT_CONVERSION = YES; 351 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 352 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 353 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 354 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 355 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 356 | CLANG_WARN_STRICT_PROTOTYPES = YES; 357 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 358 | CLANG_WARN_UNREACHABLE_CODE = YES; 359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 361 | COPY_PHASE_STRIP = NO; 362 | DEBUG_INFORMATION_FORMAT = dwarf; 363 | ENABLE_STRICT_OBJC_MSGSEND = YES; 364 | ENABLE_TESTABILITY = YES; 365 | GCC_C_LANGUAGE_STANDARD = gnu99; 366 | GCC_DYNAMIC_NO_PIC = NO; 367 | GCC_NO_COMMON_BLOCKS = YES; 368 | GCC_OPTIMIZATION_LEVEL = 0; 369 | GCC_PREPROCESSOR_DEFINITIONS = ( 370 | "DEBUG=1", 371 | "$(inherited)", 372 | ); 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 375 | GCC_WARN_UNDECLARED_SELECTOR = YES; 376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 377 | GCC_WARN_UNUSED_FUNCTION = YES; 378 | GCC_WARN_UNUSED_VARIABLE = YES; 379 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 380 | MTL_ENABLE_DEBUG_INFO = YES; 381 | ONLY_ACTIVE_ARCH = YES; 382 | SDKROOT = iphoneos; 383 | TARGETED_DEVICE_FAMILY = "1,2"; 384 | }; 385 | name = Debug; 386 | }; 387 | 97C147041CF9000F007C117D /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_ANALYZER_NONNULL = YES; 393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 394 | CLANG_CXX_LIBRARY = "libc++"; 395 | CLANG_ENABLE_MODULES = YES; 396 | CLANG_ENABLE_OBJC_ARC = YES; 397 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 398 | CLANG_WARN_BOOL_CONVERSION = YES; 399 | CLANG_WARN_COMMA = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INFINITE_RECURSION = YES; 406 | CLANG_WARN_INT_CONVERSION = YES; 407 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 409 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 411 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 412 | CLANG_WARN_STRICT_PROTOTYPES = YES; 413 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 414 | CLANG_WARN_UNREACHABLE_CODE = YES; 415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 416 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 417 | COPY_PHASE_STRIP = NO; 418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 419 | ENABLE_NS_ASSERTIONS = NO; 420 | ENABLE_STRICT_OBJC_MSGSEND = YES; 421 | GCC_C_LANGUAGE_STANDARD = gnu99; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 425 | GCC_WARN_UNDECLARED_SELECTOR = YES; 426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 427 | GCC_WARN_UNUSED_FUNCTION = YES; 428 | GCC_WARN_UNUSED_VARIABLE = YES; 429 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 430 | MTL_ENABLE_DEBUG_INFO = NO; 431 | SDKROOT = iphoneos; 432 | SUPPORTED_PLATFORMS = iphoneos; 433 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 434 | TARGETED_DEVICE_FAMILY = "1,2"; 435 | VALIDATE_PRODUCT = YES; 436 | }; 437 | name = Release; 438 | }; 439 | 97C147061CF9000F007C117D /* Debug */ = { 440 | isa = XCBuildConfiguration; 441 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | CLANG_ENABLE_MODULES = YES; 445 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 446 | ENABLE_BITCODE = NO; 447 | FRAMEWORK_SEARCH_PATHS = ( 448 | "$(inherited)", 449 | "$(PROJECT_DIR)/Flutter", 450 | ); 451 | INFOPLIST_FILE = Runner/Info.plist; 452 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 453 | LIBRARY_SEARCH_PATHS = ( 454 | "$(inherited)", 455 | "$(PROJECT_DIR)/Flutter", 456 | ); 457 | PRODUCT_BUNDLE_IDENTIFIER = clean_architecture.with_bloc; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 460 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 461 | SWIFT_VERSION = 5.0; 462 | VERSIONING_SYSTEM = "apple-generic"; 463 | }; 464 | name = Debug; 465 | }; 466 | 97C147071CF9000F007C117D /* Release */ = { 467 | isa = XCBuildConfiguration; 468 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 469 | buildSettings = { 470 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 471 | CLANG_ENABLE_MODULES = YES; 472 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 473 | ENABLE_BITCODE = NO; 474 | FRAMEWORK_SEARCH_PATHS = ( 475 | "$(inherited)", 476 | "$(PROJECT_DIR)/Flutter", 477 | ); 478 | INFOPLIST_FILE = Runner/Info.plist; 479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 480 | LIBRARY_SEARCH_PATHS = ( 481 | "$(inherited)", 482 | "$(PROJECT_DIR)/Flutter", 483 | ); 484 | PRODUCT_BUNDLE_IDENTIFIER = clean_architecture.with_bloc; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 487 | SWIFT_VERSION = 5.0; 488 | VERSIONING_SYSTEM = "apple-generic"; 489 | }; 490 | name = Release; 491 | }; 492 | /* End XCBuildConfiguration section */ 493 | 494 | /* Begin XCConfigurationList section */ 495 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 97C147031CF9000F007C117D /* Debug */, 499 | 97C147041CF9000F007C117D /* Release */, 500 | 249021D3217E4FDB00AE95B9 /* Profile */, 501 | ); 502 | defaultConfigurationIsVisible = 0; 503 | defaultConfigurationName = Release; 504 | }; 505 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 506 | isa = XCConfigurationList; 507 | buildConfigurations = ( 508 | 97C147061CF9000F007C117D /* Debug */, 509 | 97C147071CF9000F007C117D /* Release */, 510 | 249021D4217E4FDB00AE95B9 /* Profile */, 511 | ); 512 | defaultConfigurationIsVisible = 0; 513 | defaultConfigurationName = Release; 514 | }; 515 | /* End XCConfigurationList section */ 516 | }; 517 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 518 | } 519 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/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/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasithaAthukorala/flutter-clean-architecture-sample/f672199b964e718df41022787228c949802bb047/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | clean_architecture_with_bloc 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /lib/core/error/exceptions.dart: -------------------------------------------------------------------------------- 1 | class ServerException implements Exception {} 2 | 3 | class CacheException implements Exception {} 4 | -------------------------------------------------------------------------------- /lib/core/error/failures.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | abstract class Failure extends Equatable { 4 | Failure([List properties = const []]) : super(properties); 5 | } 6 | 7 | class ServerFailure extends Failure {} 8 | 9 | class CacheFailure extends Failure {} 10 | 11 | class NoConnectionFailure extends Failure {} 12 | -------------------------------------------------------------------------------- /lib/core/network/network_info.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_connection_checker/data_connection_checker.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | 4 | abstract class NetworkInfo { 5 | Future get isConnected; 6 | } 7 | 8 | class NetworkInfoImpl implements NetworkInfo { 9 | final DataConnectionChecker dataConnectionChecker; 10 | 11 | NetworkInfoImpl({@required this.dataConnectionChecker}); 12 | 13 | @override 14 | Future get isConnected => dataConnectionChecker.hasConnection; 15 | } 16 | -------------------------------------------------------------------------------- /lib/core/network/rest_client_service.chopper.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'rest_client_service.dart'; 4 | 5 | // ************************************************************************** 6 | // ChopperGenerator 7 | // ************************************************************************** 8 | 9 | class _$RestClientService extends RestClientService { 10 | _$RestClientService([ChopperClient client]) { 11 | if (client == null) return; 12 | this.client = client; 13 | } 14 | 15 | final definitionType = RestClientService; 16 | 17 | Future loginUser(String jsonBody) { 18 | final $url = 'BASE_URL/tokens'; 19 | final $headers = {'Content-type': 'application/json'}; 20 | final $body = jsonBody; 21 | final $request = 22 | Request('POST', $url, client.baseUrl, body: $body, headers: $headers); 23 | return client.send($request); 24 | } 25 | 26 | Future logoutUser(String jsonBody, String token) { 27 | final $url = 'BASE_URL/tokens'; 28 | final $headers = { 29 | 'Authorization': token, 30 | 'Content-type': 'application/json' 31 | }; 32 | final $body = jsonBody; 33 | final $request = 34 | Request('DELETE', $url, client.baseUrl, body: $body, headers: $headers); 35 | return client.send($request); 36 | } 37 | 38 | Future changePassword(String jsonBody) { 39 | final $url = 'BASE_URL/create'; 40 | final $headers = {'Content-type': 'application/json'}; 41 | final $body = jsonBody; 42 | final $request = 43 | Request('PUT', $url, client.baseUrl, body: $body, headers: $headers); 44 | return client.send($request); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/core/network/rest_client_service.dart: -------------------------------------------------------------------------------- 1 | import "dart:async"; 2 | 3 | import 'package:chopper/chopper.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 5 | 6 | part "rest_client_service.chopper.dart"; 7 | 8 | @ChopperApi(baseUrl: API_BASE_URL) 9 | abstract class RestClientService extends ChopperService { 10 | static RestClientService create([ChopperClient client]) => 11 | _$RestClientService(client); 12 | 13 | @Post(path: LOGIN_USER, headers: {'Content-type': 'application/json'}) 14 | Future loginUser(@Body() String jsonBody); 15 | 16 | @Delete(path: LOGIN_USER, headers: {'Content-type': 'application/json'}) 17 | Future logoutUser( 18 | @Body() String jsonBody, @Header("Authorization") String token); 19 | 20 | @Put(path: CREATE_USER, headers: {'Content-type': 'application/json'}) 21 | Future changePassword(@Body() String jsonBody); 22 | } 23 | -------------------------------------------------------------------------------- /lib/core/usecases/fetch_token.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/usecases/usecase.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/repositories/login_repository.dart'; 8 | 9 | class FetchToken implements UseCase { 10 | final LoginRepository repository; 11 | 12 | FetchToken({@required this.repository}); 13 | 14 | @override 15 | Future> call(TokenParams params) async { 16 | return await repository.fetchCachedToken(); 17 | } 18 | } 19 | 20 | class TokenParams extends Equatable {} 21 | -------------------------------------------------------------------------------- /lib/core/usecases/usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 3 | 4 | abstract class UseCase { 5 | Future> call(Params params); 6 | } 7 | -------------------------------------------------------------------------------- /lib/core/utils/constants.dart: -------------------------------------------------------------------------------- 1 | const String CACHED_TOKEN = 'CACHED_TOKEN'; 2 | 3 | const String API_BASE_URL = 'BASE_URL'; // add the base url here 4 | const String LOGIN_USER = 'tokens'; 5 | const String CREATE_USER = 'create'; 6 | 7 | const String LOGGING_ERROR = 8 | 'Could not login successfully, please check your email and password'; 9 | const String LOGGING_OUT_ERROR = 10 | 'Could not logout successfully, please try again later'; 11 | const String NO_CONNECTION_ERROR = 'You are not connected to the Internet'; 12 | const String CHANGE_PASSWORD_ERROR = 13 | 'Could not change the password. Please try again later'; 14 | 15 | const double DEFAULT_PAGE_PADDING = 20; 16 | 17 | //routes 18 | const String HOME_ROUTE = '/'; 19 | const String LOGIN_ROUTE = '/login'; 20 | const String CHANGE_PASSWORD_ROUTE = '/change_password'; 21 | -------------------------------------------------------------------------------- /lib/core/utils/router.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:clean_architecture_with_bloc_app/screens/change_password/presentation/page/change_password.dart'; 3 | import 'package:clean_architecture_with_bloc_app/screens/home/presentation/page/home.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/login/presentation/page/login.dart'; 5 | import 'constants.dart'; 6 | 7 | class Router { 8 | static Route generateRoute(RouteSettings settings) { 9 | switch (settings.name) { 10 | case LOGIN_ROUTE: 11 | return MaterialPageRoute(builder: (_) => LoginPage()); 12 | case HOME_ROUTE: 13 | return MaterialPageRoute(builder: (_) => HomePage()); 14 | case CHANGE_PASSWORD_ROUTE: 15 | return MaterialPageRoute(builder: (_) => ChangePasswordPage()); 16 | default: 17 | return MaterialPageRoute(builder: (_) => LoginPage()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/core/utils/theme.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | class CustomColor { 6 | static const Color white = Color(0xFFFFFFFF); 7 | static const Color fontBlack = Color(0xDE000000); 8 | static const Color logoBlue = Color(0xFF245f97); 9 | static const Color textFieldBackground = Color(0x1E000000); 10 | static const Color hintColor = Color(0x99000000); 11 | static const Color statusBarColor = Color(0x1e000000); 12 | } 13 | 14 | class CustomTheme { 15 | static ThemeData mainTheme = ThemeData( 16 | // Default brightness and colors. 17 | brightness: Brightness.light, 18 | primaryColor: CustomColor.logoBlue, 19 | accentColor: Colors.cyan[600], 20 | 21 | // Default font family. 22 | fontFamily: 'Roboto', 23 | 24 | // Default TextTheme. Use this to specify the default 25 | // text styling for headlines, titles, bodies of text, and etc. 26 | textTheme: TextTheme( 27 | headline: TextStyle( 28 | fontSize: 20.0, 29 | fontWeight: FontWeight.bold, 30 | color: CustomColor.fontBlack, 31 | ), 32 | title: TextStyle( 33 | fontSize: 18.0, 34 | fontWeight: FontWeight.bold, 35 | color: CustomColor.fontBlack, 36 | ), 37 | body1: TextStyle(fontSize: 16.0, color: CustomColor.fontBlack), 38 | body2: TextStyle(fontSize: 16.0, color: CustomColor.hintColor), 39 | button: TextStyle( 40 | color: CustomColor.white, 41 | fontFamily: 'Roboto', 42 | fontWeight: FontWeight.w500, 43 | fontSize: 14, 44 | letterSpacing: 2, 45 | ), 46 | ), 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /lib/core/widgets/custom_snak_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CustomSnackBar { 4 | final GlobalKey scaffoldKey; 5 | final ScaffoldState scaffoldState; 6 | final Key key; 7 | 8 | CustomSnackBar({this.key, this.scaffoldKey, this.scaffoldState}) 9 | : assert(scaffoldState != null || scaffoldKey != null); 10 | 11 | void showErrorSnackBar(final msg) { 12 | showSnackBar(text: "Error: $msg", color: Colors.red[400]); 13 | } 14 | 15 | ScaffoldState get _state { 16 | return scaffoldKey == null ? scaffoldState : scaffoldKey.currentState; 17 | } 18 | 19 | void showLoadingSnackBar() { 20 | hideAll(); 21 | final snackBar = SnackBar( 22 | key: key, 23 | content: Row( 24 | children: [ 25 | CircularProgressIndicator(), 26 | SizedBox(width: 10.0), 27 | Text("Loading..."), 28 | ], 29 | ), 30 | backgroundColor: Colors.green[400], 31 | duration: Duration(minutes: 1), 32 | ); 33 | _state?.showSnackBar(snackBar); 34 | } 35 | 36 | void showSnackBar({ 37 | @required String text, 38 | Duration duration = const Duration(hours: 1), 39 | Color color, 40 | bool action = true, 41 | }) { 42 | hideAll(); 43 | final snackBar = SnackBar( 44 | key: key, 45 | content: Text( 46 | text, 47 | maxLines: 2, 48 | overflow: TextOverflow.ellipsis, 49 | ), 50 | backgroundColor: color ?? Colors.green[400], 51 | duration: duration, 52 | action: action 53 | ? SnackBarAction( 54 | label: "Clear", 55 | textColor: Colors.black, 56 | onPressed: () => _state.removeCurrentSnackBar(), 57 | ) 58 | : null, 59 | ); 60 | _state?.showSnackBar(snackBar); 61 | } 62 | 63 | void hideAll() { 64 | _state?.removeCurrentSnackBar(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/injection_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:chopper/chopper.dart'; 2 | import 'package:data_connection_checker/data_connection_checker.dart'; 3 | import 'package:get_it/get_it.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/datasources/change_password_remote_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/repositories/change_password_repository_impl.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/repositories/change_password_repository.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/usecases/change_password.dart'; 10 | import 'package:clean_architecture_with_bloc_app/screens/change_password/presentation/blocs/change_password/bloc.dart'; 11 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_local_datasource.dart'; 12 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_remote_datasource.dart'; 13 | import 'package:clean_architecture_with_bloc_app/screens/home/data/repositories/home_repository_impl.dart'; 14 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/repositories/home_repository.dart'; 15 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/usecases/logout_user.dart'; 16 | import 'package:clean_architecture_with_bloc_app/screens/home/presentation/blocs/log_out/bloc.dart'; 17 | import 'package:clean_architecture_with_bloc_app/screens/login/data/repositories/login_repository_impl.dart'; 18 | import 'package:clean_architecture_with_bloc_app/core/usecases/fetch_token.dart'; 19 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/usecases/login_user.dart'; 20 | import 'package:clean_architecture_with_bloc_app/screens/login/presentation/blocs/user_login/bloc.dart'; 21 | import 'package:shared_preferences/shared_preferences.dart'; 22 | 23 | import 'screens/change_password/data/datasources/change_password_local_datasource.dart'; 24 | import 'screens/login/data/datasources/login_local_datasource.dart'; 25 | import 'screens/login/data/datasources/login_remote_datasource.dart'; 26 | import 'screens/login/domain/repositories/login_repository.dart'; 27 | 28 | final sl = GetIt.instance; //sl is referred to as Service Locator 29 | 30 | //Dependency injection 31 | Future init() async { 32 | //Blocs 33 | sl.registerFactory( 34 | () => UserLoginBloc( 35 | loginUser: sl(), 36 | fetchToken: sl(), 37 | )..add(CheckLoginStatusEvent()), 38 | ); 39 | sl.registerFactory( 40 | () => LogOutBloc( 41 | fetchToken: sl(), 42 | logoutUser: sl(), 43 | ), 44 | ); 45 | sl.registerFactory( 46 | () => ChangePasswordBloc( 47 | changePassword: sl(), 48 | ), 49 | ); 50 | 51 | //Use cases 52 | sl.registerLazySingleton(() => LoginUser(repository: sl())); 53 | sl.registerLazySingleton(() => FetchToken(repository: sl())); 54 | sl.registerLazySingleton(() => LogOutUser(repository: sl())); 55 | sl.registerLazySingleton(() => ChangePassword(repository: sl())); 56 | 57 | //Repositories 58 | sl.registerLazySingleton( 59 | () => LoginRepositoryImpl( 60 | networkInfo: sl(), 61 | localDataSource: sl(), 62 | remoteDataSource: sl(), 63 | ), 64 | ); 65 | sl.registerLazySingleton(() => HomeRepositoryImpl( 66 | networkInfo: sl(), 67 | localDataSource: sl(), 68 | remoteDataSource: sl(), 69 | )); 70 | sl.registerLazySingleton(() => ChangePasswordRepositoryImpl( 71 | networkInfo: sl(), 72 | localDataSource: sl(), 73 | remoteDataSource: sl(), 74 | )); 75 | 76 | 77 | //Data sources 78 | sl.registerLazySingleton( 79 | () => LoginRemoteDataSourceImpl( 80 | restClientService: sl(), 81 | ), 82 | ); 83 | sl.registerLazySingleton( 84 | () => LoginLocalDataSourceImpl( 85 | sharedPreferences: sl(), 86 | ), 87 | ); 88 | sl.registerLazySingleton( 89 | () => HomeRemoteDataSourceImpl( 90 | restClientService: sl(), 91 | ), 92 | ); 93 | sl.registerLazySingleton( 94 | () => HomeLocalDataSourceImpl( 95 | sharedPreferences: sl(), 96 | ), 97 | ); 98 | sl.registerLazySingleton( 99 | () => ChangePasswordRemoteDataSourceImpl( 100 | restClientService: sl(), 101 | ), 102 | ); 103 | sl.registerLazySingleton( 104 | () => ChangePasswordLocalDataSourceImpl( 105 | sharedPreferences: sl(), 106 | ), 107 | ); 108 | 109 | //Core 110 | sl.registerLazySingleton( 111 | () => NetworkInfoImpl(dataConnectionChecker: sl()), 112 | ); 113 | 114 | //External 115 | final SharedPreferences sharedPreferences = 116 | await SharedPreferences.getInstance(); 117 | sl.registerLazySingleton(() => sharedPreferences); 118 | sl.registerLazySingleton(() => DataConnectionChecker()); 119 | final client = ChopperClient(interceptors: [ 120 | CurlInterceptor(), 121 | HttpLoggingInterceptor(), 122 | ]); 123 | sl.registerLazySingleton(() => RestClientService.create(client)); 124 | } 125 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/utils/theme.dart'; 4 | import 'package:logging/logging.dart'; 5 | import 'core/utils/router.dart'; 6 | import 'injection_container.dart' as di; //Dependency injector 7 | 8 | void main() async { 9 | WidgetsFlutterBinding.ensureInitialized(); 10 | await di 11 | .init(); //Inject all the dependencies and wait for it is done (i.e. UI won't built until all the dependencies are injected) 12 | _setupLogging(); 13 | runApp(CleanArchitectureWithBloc()); 14 | } 15 | 16 | class CleanArchitectureWithBloc extends StatelessWidget { 17 | // This widget is the root of the application. 18 | @override 19 | Widget build(BuildContext context) { 20 | return MaterialApp( 21 | debugShowCheckedModeBanner: false, 22 | title: 'clean architecture with bloc', 23 | theme: CustomTheme.mainTheme, 24 | onGenerateRoute: Router.generateRoute, 25 | initialRoute: LOGIN_ROUTE, 26 | ); 27 | } 28 | } 29 | 30 | void _setupLogging() { 31 | Logger.root.level = Level.ALL; 32 | Logger.root.onRecord.listen((rec) { 33 | print('${rec.level.name}: ${rec.time}: ${rec.message}'); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /lib/screens/change_password/data/datasources/change_password_local_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | abstract class ChangePasswordLocalDataSource { 5 | //TODO: Add use cases 6 | } 7 | 8 | class ChangePasswordLocalDataSourceImpl extends ChangePasswordLocalDataSource { 9 | final SharedPreferences sharedPreferences; 10 | 11 | ChangePasswordLocalDataSourceImpl({@required this.sharedPreferences}); 12 | } -------------------------------------------------------------------------------- /lib/screens/change_password/data/datasources/change_password_remote_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 6 | 7 | abstract class ChangePasswordRemoteDataSource { 8 | Future changePassword(String oldPassword, String newPassword); 9 | } 10 | 11 | class ChangePasswordRemoteDataSourceImpl extends ChangePasswordRemoteDataSource { 12 | final RestClientService restClientService; 13 | 14 | ChangePasswordRemoteDataSourceImpl({@required this.restClientService}); 15 | 16 | @override 17 | Future changePassword(String oldPassword, String newPassword) async { 18 | final response = await restClientService.changePassword( 19 | jsonEncode({ 20 | 'oldPassword': oldPassword, 21 | 'newPassword': newPassword, 22 | }), 23 | ); 24 | if (response.statusCode != 204) { 25 | throw ServerException(); 26 | } 27 | return true; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/screens/change_password/data/repositories/change_password_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/datasources/change_password_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/datasources/change_password_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/repositories/change_password_repository.dart'; 9 | 10 | class ChangePasswordRepositoryImpl implements ChangePasswordRepository { 11 | final ChangePasswordRemoteDataSource remoteDataSource; 12 | final ChangePasswordLocalDataSource localDataSource; 13 | final NetworkInfo networkInfo; 14 | 15 | ChangePasswordRepositoryImpl( 16 | {@required this.remoteDataSource, 17 | @required this.localDataSource, 18 | @required this.networkInfo}); 19 | 20 | @override 21 | Future> changePassword(String oldPassword, String newPassword) async { 22 | if (await networkInfo.isConnected) { 23 | try { 24 | final result = await remoteDataSource.changePassword(oldPassword, newPassword); 25 | return Right(result); 26 | } on ServerException { 27 | return Left(ServerFailure()); 28 | } 29 | } else { 30 | return Left(NoConnectionFailure()); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/screens/change_password/domain/repositories/change_password_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 3 | 4 | abstract class ChangePasswordRepository { 5 | Future> changePassword(String oldPassword, String newPassword); 6 | } -------------------------------------------------------------------------------- /lib/screens/change_password/domain/usecases/change_password.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/usecases/usecase.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/repositories/change_password_repository.dart'; 7 | 8 | class ChangePassword extends UseCase{ 9 | final ChangePasswordRepository repository; 10 | 11 | ChangePassword({this.repository}); 12 | 13 | @override 14 | Future> call(ChangePasswordParams params) { 15 | return repository.changePassword(params.oldPassword, params.newPassword); 16 | } 17 | } 18 | 19 | class ChangePasswordParams extends Equatable{ 20 | final String oldPassword; 21 | final String newPassword; 22 | 23 | ChangePasswordParams({@required this.oldPassword, @required this.newPassword}); 24 | } -------------------------------------------------------------------------------- /lib/screens/change_password/presentation/blocs/change_password/bloc.dart: -------------------------------------------------------------------------------- 1 | export 'change_password_bloc.dart'; 2 | export 'change_password_event.dart'; 3 | export 'change_password_state.dart'; -------------------------------------------------------------------------------- /lib/screens/change_password/presentation/blocs/change_password/change_password_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/usecases/change_password.dart'; 7 | 8 | import 'bloc.dart'; 9 | 10 | class ChangePasswordBloc 11 | extends Bloc { 12 | final ChangePassword changePassword; 13 | 14 | ChangePasswordBloc({@required this.changePassword}); 15 | 16 | @override 17 | ChangePasswordState get initialState => InitialState(); 18 | 19 | @override 20 | Stream mapEventToState( 21 | ChangePasswordEvent event) async* { 22 | if (event is PasswordChangeEvent) { 23 | yield LoadingState(); 24 | final result = await changePassword(ChangePasswordParams( 25 | oldPassword: event.oldPassword, 26 | newPassword: event.newPassword, 27 | )); 28 | yield* result.fold((failure) async* { 29 | yield ErrorState(CHANGE_PASSWORD_ERROR); 30 | }, (success) async* { 31 | yield SuccessfulState(); 32 | }); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/screens/change_password/presentation/blocs/change_password/change_password_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:meta/meta.dart'; 3 | 4 | @immutable 5 | abstract class ChangePasswordEvent extends Equatable { 6 | ChangePasswordEvent([List props = const []]) : super(props); 7 | } 8 | 9 | class PasswordChangeEvent extends ChangePasswordEvent { 10 | final String oldPassword; 11 | final String newPassword; 12 | 13 | PasswordChangeEvent({@required this.oldPassword, @required this.newPassword}); 14 | } -------------------------------------------------------------------------------- /lib/screens/change_password/presentation/blocs/change_password/change_password_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:meta/meta.dart'; 3 | 4 | @immutable 5 | abstract class ChangePasswordState extends Equatable { 6 | ChangePasswordState([List props = const []]) : super(props); 7 | } 8 | 9 | class InitialState extends ChangePasswordState {} 10 | 11 | class LoadingState extends ChangePasswordState {} 12 | 13 | class SuccessfulState extends ChangePasswordState {} 14 | 15 | class ErrorState extends ChangePasswordState { 16 | final String message; 17 | 18 | ErrorState(this.message); 19 | } -------------------------------------------------------------------------------- /lib/screens/change_password/presentation/page/change_password.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/utils/theme.dart'; 7 | import 'package:clean_architecture_with_bloc_app/core/widgets/custom_snak_bar.dart'; 8 | import 'package:clean_architecture_with_bloc_app/injection_container.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/change_password/presentation/blocs/change_password/bloc.dart'; 10 | 11 | class ChangePasswordPage extends StatefulWidget { 12 | @override 13 | State createState() => _ChangePasswordPageState(); 14 | } 15 | 16 | class _ChangePasswordPageState extends State { 17 | final TextEditingController _oldPasswordController = TextEditingController(); 18 | final TextEditingController _passwordController = TextEditingController(); 19 | final TextEditingController _passwordConfirmController = 20 | TextEditingController(); 21 | 22 | final FocusNode _oldPasswordNode = FocusNode(); 23 | final FocusNode _passwordNode = FocusNode(); 24 | final FocusNode _passwordConfirmNode = FocusNode(); 25 | final FocusNode _viewNode = FocusNode(); 26 | 27 | final _scaffoldKey = GlobalKey(); 28 | 29 | CustomSnackBar _snackBar; 30 | BooleanPrimitiveWrapper _obscureOldPasswordText; 31 | BooleanPrimitiveWrapper _obscurePasswordText; 32 | BooleanPrimitiveWrapper _obscurePasswordConfirmText; 33 | 34 | @override 35 | void initState() { 36 | super.initState(); 37 | _obscureOldPasswordText = BooleanPrimitiveWrapper(true); 38 | _obscurePasswordText = BooleanPrimitiveWrapper(true); 39 | _obscurePasswordConfirmText = BooleanPrimitiveWrapper(true); 40 | } 41 | 42 | @override 43 | void dispose() { 44 | _oldPasswordNode?.dispose(); 45 | _passwordNode?.dispose(); 46 | _viewNode?.dispose(); 47 | _oldPasswordController.dispose(); 48 | _passwordController.dispose(); 49 | _passwordConfirmController.dispose(); 50 | super.dispose(); 51 | } 52 | 53 | @override 54 | Widget build(BuildContext context) { 55 | _snackBar = CustomSnackBar(key: Key("snackbar"), scaffoldKey: _scaffoldKey); 56 | return GestureDetector( 57 | onTap: () => FocusScope.of(context).requestFocus(_viewNode), 58 | child: Scaffold( 59 | key: _scaffoldKey, 60 | body: AnnotatedRegion( 61 | value: SystemUiOverlayStyle.dark.copyWith( 62 | statusBarColor: CustomColor.statusBarColor, 63 | ), 64 | child: _buildBody(context), 65 | ), 66 | appBar: AppBar( 67 | iconTheme: CustomTheme.mainTheme.iconTheme, 68 | textTheme: CustomTheme.mainTheme.textTheme, 69 | backgroundColor: CustomColor.white, 70 | centerTitle: true, 71 | title: Text( 72 | "Change Password", 73 | style: CustomTheme.mainTheme.textTheme.headline, 74 | ), 75 | brightness: Brightness.light, 76 | ), 77 | ), 78 | ); 79 | } 80 | 81 | BlocProvider _buildBody(BuildContext context) { 82 | final Size size = MediaQuery.of(context).size; 83 | return BlocProvider( 84 | create: (_) => sl(), 85 | child: Container( 86 | height: size.height, 87 | width: size.width, 88 | padding: EdgeInsets.all(DEFAULT_PAGE_PADDING), 89 | child: SingleChildScrollView( 90 | child: Column( 91 | crossAxisAlignment: CrossAxisAlignment.center, 92 | mainAxisAlignment: MainAxisAlignment.start, 93 | children: [ 94 | Padding( 95 | padding: EdgeInsets.only(top: 12), 96 | ), 97 | _buildPasswordField( 98 | context, 99 | _oldPasswordNode, 100 | _oldPasswordController, 101 | _obscureOldPasswordText, 102 | "Old Password*", 103 | _passwordNode, 104 | ), 105 | Padding( 106 | padding: EdgeInsets.only(top: 12), 107 | ), 108 | _buildPasswordField( 109 | context, 110 | _passwordNode, 111 | _passwordController, 112 | _obscurePasswordText, 113 | "New Password*", 114 | _passwordConfirmNode, 115 | ), 116 | Padding( 117 | padding: EdgeInsets.only(top: 12), 118 | ), 119 | _buildPasswordField( 120 | context, 121 | _passwordConfirmNode, 122 | _passwordConfirmController, 123 | _obscurePasswordConfirmText, 124 | "Confirm Password*", 125 | _viewNode, 126 | ), 127 | Padding( 128 | padding: EdgeInsets.only(top: 14), 129 | ), 130 | Container( 131 | width: double.infinity, 132 | height: 36, 133 | child: _buildChangePasswordButton(), 134 | ), 135 | ], 136 | ), 137 | ), 138 | ), 139 | ); 140 | } 141 | 142 | BlocBuilder _buildChangePasswordButton() { 143 | return BlocBuilder( 144 | condition: (prevState, currState) { 145 | if (currState is SuccessfulState) { 146 | _snackBar.hideAll(); 147 | Navigator.pushNamedAndRemoveUntil(context, HOME_ROUTE, (r) => false); 148 | } 149 | return !(currState is SuccessfulState); 150 | }, 151 | builder: (context, state) { 152 | if (state is InitialState) { 153 | return RaisedButton( 154 | key: Key("changePassword"), 155 | shape: RoundedRectangleBorder( 156 | borderRadius: new BorderRadius.circular(4.0), 157 | ), 158 | color: CustomColor.logoBlue, 159 | onPressed: () { 160 | if (_oldPasswordController.text.isNotEmpty && 161 | _passwordController.text.isNotEmpty && 162 | _passwordConfirmController.text.isNotEmpty) { 163 | if (_passwordController.text == 164 | _passwordConfirmController.text) { 165 | BlocProvider.of(context).add( 166 | PasswordChangeEvent( 167 | oldPassword: _oldPasswordController.text, 168 | newPassword: _passwordController.text, 169 | ), 170 | ); 171 | } else { 172 | _snackBar.hideAll(); 173 | _snackBar.showErrorSnackBar("Passwords do not match"); 174 | } 175 | } else { 176 | _snackBar.hideAll(); 177 | _snackBar.showErrorSnackBar("Fileds can't be empty"); 178 | } 179 | }, 180 | child: Text( 181 | "CHANGE PASSWORD", 182 | style: CustomTheme.mainTheme.textTheme.button, 183 | ), 184 | ); 185 | } else if (state is LoadingState) { 186 | WidgetsBinding.instance.addPostFrameCallback((_) { 187 | _snackBar.hideAll(); 188 | _snackBar.showLoadingSnackBar(); 189 | }); 190 | return Container(); 191 | } else if (state is ErrorState) { 192 | WidgetsBinding.instance.addPostFrameCallback((_) { 193 | _snackBar.hideAll(); 194 | _snackBar.showErrorSnackBar(state.message); 195 | }); 196 | } 197 | return Container(); 198 | }, 199 | ); 200 | } 201 | 202 | TextFormField _buildPasswordField( 203 | BuildContext context, 204 | FocusNode focusNode, 205 | TextEditingController controller, 206 | BooleanPrimitiveWrapper obscureText, 207 | String labelText, 208 | FocusNode nextNode, 209 | ) { 210 | return TextFormField( 211 | focusNode: focusNode, 212 | controller: controller, 213 | obscureText: obscureText.value, 214 | keyboardType: TextInputType.visiblePassword, 215 | decoration: InputDecoration( 216 | focusedBorder: new OutlineInputBorder( 217 | borderRadius: new BorderRadius.circular(4.0), 218 | borderSide: new BorderSide( 219 | color: CustomColor.textFieldBackground, 220 | ), 221 | ), 222 | border: new OutlineInputBorder( 223 | borderRadius: new BorderRadius.circular(4.0), 224 | borderSide: new BorderSide( 225 | color: CustomColor.textFieldBackground, 226 | ), 227 | ), 228 | enabledBorder: new OutlineInputBorder( 229 | borderRadius: new BorderRadius.circular(4.0), 230 | borderSide: new BorderSide( 231 | color: CustomColor.textFieldBackground, 232 | ), 233 | ), 234 | focusColor: CustomColor.hintColor, 235 | hoverColor: CustomColor.hintColor, 236 | fillColor: CustomColor.textFieldBackground, 237 | filled: true, 238 | labelText: labelText, 239 | labelStyle: CustomTheme.mainTheme.textTheme.body2, 240 | suffixIcon: IconButton( 241 | icon: Icon(Icons.remove_red_eye), 242 | color: CustomColor.hintColor, 243 | onPressed: () { 244 | setState(() { 245 | obscureText.value = !obscureText.value; 246 | }); 247 | }, 248 | ), 249 | ), 250 | cursorColor: CustomColor.hintColor, 251 | onFieldSubmitted: (term) { 252 | _fieldFocusChange(context, focusNode, nextNode); 253 | }, 254 | ); 255 | } 256 | 257 | _fieldFocusChange( 258 | BuildContext context, FocusNode currentFocus, FocusNode nextFocus) { 259 | currentFocus.unfocus(); 260 | FocusScope.of(context).requestFocus(nextFocus); 261 | } 262 | } 263 | 264 | class BooleanPrimitiveWrapper { 265 | bool value; 266 | 267 | BooleanPrimitiveWrapper(this.value); 268 | } 269 | -------------------------------------------------------------------------------- /lib/screens/home/data/datasources/home_local_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | 6 | abstract class HomeLocalDataSource { 7 | Future clearToken(); 8 | } 9 | 10 | class HomeLocalDataSourceImpl extends HomeLocalDataSource { 11 | final SharedPreferences sharedPreferences; 12 | 13 | HomeLocalDataSourceImpl({@required this.sharedPreferences}); 14 | 15 | @override 16 | Future clearToken() async { 17 | bool removed = await sharedPreferences.remove(CACHED_TOKEN); 18 | if (!removed) { 19 | throw CacheException(); 20 | } 21 | return removed; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/screens/home/data/datasources/home_remote_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 6 | 7 | abstract class HomeRemoteDataSource { 8 | Future logoutUser(String token); 9 | } 10 | 11 | class HomeRemoteDataSourceImpl extends HomeRemoteDataSource { 12 | final RestClientService restClientService; 13 | 14 | HomeRemoteDataSourceImpl({@required this.restClientService}); 15 | 16 | @override 17 | Future logoutUser(String token) async { 18 | final response = await restClientService.logoutUser( 19 | jsonEncode({ 20 | 'token': token, 21 | }), 22 | token); 23 | if (response.statusCode != 204) { 24 | throw ServerException(); 25 | } 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/screens/home/data/repositories/home_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/repositories/home_repository.dart'; 9 | 10 | class HomeRepositoryImpl implements HomeRepository { 11 | final HomeRemoteDataSource remoteDataSource; 12 | final HomeLocalDataSource localDataSource; 13 | final NetworkInfo networkInfo; 14 | 15 | HomeRepositoryImpl( 16 | {@required this.remoteDataSource, 17 | @required this.localDataSource, 18 | @required this.networkInfo}); 19 | 20 | @override 21 | Future> logoutUser(String token) async { 22 | if (await networkInfo.isConnected) { 23 | try { 24 | await remoteDataSource.logoutUser(token); 25 | try { 26 | await localDataSource.clearToken(); 27 | return Right(true); 28 | } on CacheException { 29 | return Left(CacheFailure()); 30 | } 31 | } on ServerException { 32 | return Left(ServerFailure()); 33 | } 34 | } else { 35 | return Left(NoConnectionFailure()); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/screens/home/domain/repositories/home_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 3 | 4 | abstract class HomeRepository { 5 | Future> logoutUser(String token); 6 | } 7 | -------------------------------------------------------------------------------- /lib/screens/home/domain/usecases/logout_user.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/usecases/usecase.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/repositories/home_repository.dart'; 7 | 8 | class LogOutUser implements UseCase { 9 | final HomeRepository repository; 10 | 11 | LogOutUser({@required this.repository}); 12 | 13 | @override 14 | Future> call(LogOutParams params) async { 15 | return await repository.logoutUser(params.token); 16 | } 17 | } 18 | 19 | class LogOutParams extends Equatable { 20 | final String token; 21 | LogOutParams({@required this.token}) : super([token]); 22 | } 23 | -------------------------------------------------------------------------------- /lib/screens/home/presentation/blocs/log_out/bloc.dart: -------------------------------------------------------------------------------- 1 | export 'log_out_bloc.dart'; 2 | export 'log_out_event.dart'; 3 | export 'log_out_state.dart'; 4 | -------------------------------------------------------------------------------- /lib/screens/home/presentation/blocs/log_out/log_out_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/usecases/fetch_token.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/usecases/logout_user.dart'; 8 | 9 | import 'bloc.dart'; 10 | 11 | class LogOutBloc extends Bloc { 12 | final FetchToken fetchToken; 13 | final LogOutUser logoutUser; 14 | 15 | LogOutBloc({@required this.fetchToken, @required this.logoutUser}); 16 | 17 | @override 18 | LogOutState get initialState => LoggedInState(); 19 | 20 | @override 21 | Stream mapEventToState(LogOutEvent event) async* { 22 | if (event is UserLogOutEvent) { 23 | yield LoadingState(); 24 | final token = await fetchToken(TokenParams()); 25 | yield* token.fold((failure) async* { 26 | yield ErrorState(LOGGING_OUT_ERROR); 27 | }, (success) async* { 28 | final result = await logoutUser(LogOutParams(token: success.token)); 29 | yield* result.fold((failure) async* { 30 | yield ErrorState(LOGGING_OUT_ERROR); 31 | }, (success) async* { 32 | yield LoggedOutState(); 33 | }); 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/screens/home/presentation/blocs/log_out/log_out_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:meta/meta.dart'; 3 | 4 | @immutable 5 | abstract class LogOutEvent extends Equatable { 6 | LogOutEvent([List props = const []]) : super(props); 7 | } 8 | 9 | class UserLogOutEvent extends LogOutEvent {} 10 | -------------------------------------------------------------------------------- /lib/screens/home/presentation/blocs/log_out/log_out_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:meta/meta.dart'; 3 | 4 | @immutable 5 | abstract class LogOutState extends Equatable { 6 | LogOutState([List props = const []]) : super(props); 7 | } 8 | 9 | class LoggedInState extends LogOutState {} 10 | 11 | class LoggedOutState extends LogOutState {} 12 | 13 | class LoadingState extends LogOutState {} 14 | 15 | class ErrorState extends LogOutState { 16 | final String message; 17 | 18 | ErrorState(this.message); 19 | } 20 | -------------------------------------------------------------------------------- /lib/screens/home/presentation/page/home.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/utils/theme.dart'; 7 | import 'package:clean_architecture_with_bloc_app/core/widgets/custom_snak_bar.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/home/presentation/blocs/log_out/bloc.dart'; 9 | 10 | import '../../../../injection_container.dart'; 11 | 12 | class HomePage extends StatefulWidget { 13 | @override 14 | State createState() => _HomePageState(); 15 | } 16 | 17 | class _HomePageState extends State { 18 | final _scaffoldKey = GlobalKey(); 19 | CustomSnackBar _snackBar; 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | _snackBar = CustomSnackBar(key: Key("snackbar"), scaffoldKey: _scaffoldKey); 24 | return Scaffold( 25 | key: _scaffoldKey, 26 | body: AnnotatedRegion( 27 | value: SystemUiOverlayStyle.dark.copyWith( 28 | statusBarColor: CustomColor.statusBarColor, 29 | ), 30 | child: _buildBody(context), 31 | ), 32 | ); 33 | } 34 | 35 | BlocProvider _buildBody(BuildContext context) { 36 | final Size size = MediaQuery.of(context).size; 37 | return BlocProvider( 38 | create: (_) => sl(), 39 | child: Container( 40 | height: size.height, 41 | width: size.width, 42 | padding: EdgeInsets.all(DEFAULT_PAGE_PADDING), 43 | child: Column( 44 | children: [ 45 | Padding(padding: EdgeInsets.only(top: 50)), 46 | Text( 47 | "Draft Home", 48 | style: CustomTheme.mainTheme.textTheme.title, 49 | ), 50 | Padding(padding: EdgeInsets.only(top: 50)), 51 | Column( 52 | mainAxisAlignment: MainAxisAlignment.end, 53 | mainAxisSize: MainAxisSize.max, 54 | children: [ 55 | Container( 56 | width: double.infinity, 57 | height: 36, 58 | child: _buildChangePasswordButton(), 59 | ), 60 | Padding( 61 | padding: EdgeInsets.only(top: 8), 62 | ), 63 | Container( 64 | width: double.infinity, 65 | height: 36, 66 | child: _buildSignOutButton(), 67 | ), 68 | ], 69 | ), 70 | ], 71 | ), 72 | ), 73 | ); 74 | } 75 | 76 | BlocBuilder _buildSignOutButton() { 77 | return BlocBuilder( 78 | condition: (prevState, currState) { 79 | if (currState is LoggedOutState) { 80 | _snackBar.hideAll(); 81 | Navigator.pushNamedAndRemoveUntil(context, LOGIN_ROUTE, (r) => false); 82 | } 83 | return !(currState is LoggedOutState); 84 | }, 85 | builder: (context, state) { 86 | if (state is LoggedInState || state is ErrorState) { 87 | if (state is ErrorState) { 88 | WidgetsBinding.instance.addPostFrameCallback((_) { 89 | _snackBar.hideAll(); 90 | _snackBar.showErrorSnackBar(state.message); 91 | }); 92 | } 93 | return RaisedButton( 94 | shape: RoundedRectangleBorder( 95 | borderRadius: new BorderRadius.circular(4.0), 96 | ), 97 | color: CustomColor.logoBlue, 98 | onPressed: () { 99 | BlocProvider.of(context).add(UserLogOutEvent()); 100 | }, 101 | child: Text( 102 | "SIGN OUT", 103 | style: CustomTheme.mainTheme.textTheme.button, 104 | ), 105 | ); 106 | } else if (state is LoadingState) { 107 | WidgetsBinding.instance.addPostFrameCallback((_) { 108 | _snackBar.hideAll(); 109 | _snackBar.showLoadingSnackBar(); 110 | }); 111 | return Container(); 112 | } 113 | return Container(); 114 | }, 115 | ); 116 | } 117 | 118 | RaisedButton _buildChangePasswordButton() { 119 | return RaisedButton( 120 | key: Key("changePassword"), 121 | shape: RoundedRectangleBorder( 122 | borderRadius: new BorderRadius.circular(4.0), 123 | ), 124 | color: CustomColor.logoBlue, 125 | onPressed: () { 126 | Navigator.pushNamed(context, CHANGE_PASSWORD_ROUTE); 127 | }, 128 | child: Text( 129 | "CHANGE PASSWORD", 130 | style: CustomTheme.mainTheme.textTheme.button, 131 | ), 132 | ); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /lib/screens/login/data/datasources/login_local_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/data/models/login_model.dart'; 7 | import 'package:shared_preferences/shared_preferences.dart'; 8 | 9 | abstract class LoginLocalDataSource { 10 | Future getLastToken(); 11 | Future cacheToken(LoginModel loginModel); 12 | } 13 | 14 | class LoginLocalDataSourceImpl extends LoginLocalDataSource { 15 | final SharedPreferences sharedPreferences; 16 | 17 | LoginLocalDataSourceImpl({@required this.sharedPreferences}); 18 | 19 | @override 20 | Future cacheToken(LoginModel loginModel) { 21 | return sharedPreferences.setString(CACHED_TOKEN, jsonEncode(loginModel)); 22 | } 23 | 24 | @override 25 | Future getLastToken() { 26 | String jsonStr = sharedPreferences.getString(CACHED_TOKEN); 27 | if (jsonStr == null) { 28 | throw CacheException(); 29 | } 30 | return Future.value(LoginModel.fromJson(jsonDecode(jsonStr))); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/screens/login/data/datasources/login_remote_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/data/models/login_model.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 8 | 9 | abstract class LoginRemoteDataSource { 10 | Future loginUser(String email, String password); 11 | } 12 | 13 | class LoginRemoteDataSourceImpl extends LoginRemoteDataSource { 14 | final RestClientService restClientService; 15 | 16 | LoginRemoteDataSourceImpl({@required this.restClientService}); 17 | 18 | @override 19 | Future loginUser(String email, String password) async { 20 | final response = await restClientService.loginUser(jsonEncode({ 21 | 'email': email, 22 | 'password': password, 23 | })); 24 | if (response.statusCode != 200) { 25 | throw ServerException(); 26 | } 27 | return LoginModel.fromJson(jsonDecode(response.body)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/screens/login/data/models/login_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | part 'login_model.g.dart'; 6 | 7 | @JsonSerializable() 8 | class LoginModel extends Login { 9 | LoginModel({@required String token}) : super(token: token); 10 | 11 | factory LoginModel.fromJson(Map json) => 12 | _$LoginModelFromJson(json); 13 | 14 | Map toJson() => _$LoginModelToJson(this); 15 | } 16 | -------------------------------------------------------------------------------- /lib/screens/login/data/models/login_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'login_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | LoginModel _$LoginModelFromJson(Map json) { 10 | return LoginModel( 11 | token: json['token'] as String, 12 | ); 13 | } 14 | 15 | Map _$LoginModelToJson(LoginModel instance) => 16 | { 17 | 'token': instance.token, 18 | }; 19 | -------------------------------------------------------------------------------- /lib/screens/login/data/repositories/login_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/data/datasources/login_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/data/datasources/login_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/repositories/login_repository.dart'; 10 | 11 | class LoginRepositoryImpl implements LoginRepository { 12 | final LoginRemoteDataSource remoteDataSource; 13 | final LoginLocalDataSource localDataSource; 14 | final NetworkInfo networkInfo; 15 | 16 | LoginRepositoryImpl( 17 | {@required this.remoteDataSource, 18 | @required this.localDataSource, 19 | @required this.networkInfo}); 20 | 21 | @override 22 | Future> loginUser( 23 | String email, String password) async { 24 | if (await networkInfo.isConnected) { 25 | try { 26 | final remoteData = await remoteDataSource.loginUser(email, password); 27 | localDataSource.cacheToken(remoteData); 28 | return Right(remoteData); 29 | } on ServerException { 30 | return Left(ServerFailure()); 31 | } 32 | } else { 33 | return Left(NoConnectionFailure()); 34 | } 35 | } 36 | 37 | @override 38 | Future> fetchCachedToken() async { 39 | try { 40 | final localData = await localDataSource.getLastToken(); 41 | return Right(localData); 42 | } on CacheException { 43 | return Left(CacheFailure()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/screens/login/domain/entities/login.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | 4 | class Login extends Equatable { 5 | final String token; 6 | 7 | Login({@required this.token}) : super([token]); 8 | } 9 | -------------------------------------------------------------------------------- /lib/screens/login/domain/repositories/login_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 3 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 4 | 5 | abstract class LoginRepository { 6 | Future> loginUser(String email, String password); 7 | Future> fetchCachedToken(); 8 | } 9 | -------------------------------------------------------------------------------- /lib/screens/login/domain/usecases/login_user.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/usecases/usecase.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/repositories/login_repository.dart'; 8 | 9 | class LoginUser implements UseCase { 10 | final LoginRepository repository; 11 | 12 | LoginUser({@required this.repository}); 13 | 14 | @override 15 | Future> call(LoginParams params) async { 16 | return await repository.loginUser(params.email, params.password); 17 | } 18 | } 19 | 20 | class LoginParams extends Equatable { 21 | final String email; 22 | final String password; 23 | 24 | LoginParams({@required this.email, @required this.password}) 25 | : super([email, password]); 26 | } 27 | -------------------------------------------------------------------------------- /lib/screens/login/presentation/blocs/user_login/bloc.dart: -------------------------------------------------------------------------------- 1 | export 'user_login_bloc.dart'; 2 | export 'user_login_event.dart'; 3 | export 'user_login_state.dart'; 4 | -------------------------------------------------------------------------------- /lib/screens/login/presentation/blocs/user_login/user_login_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 8 | import 'package:clean_architecture_with_bloc_app/core/usecases/fetch_token.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/usecases/login_user.dart'; 10 | 11 | import 'bloc.dart'; 12 | 13 | class UserLoginBloc extends Bloc { 14 | final LoginUser loginUser; 15 | final FetchToken fetchToken; 16 | 17 | UserLoginBloc({@required this.loginUser, @required this.fetchToken}); 18 | 19 | @override 20 | UserLoginState get initialState => NotLoggedState(); 21 | 22 | @override 23 | Stream mapEventToState(UserLoginEvent event) async* { 24 | if (event is CheckLoginStatusEvent) { 25 | yield LoadingState(); 26 | final result = await fetchToken(TokenParams()); 27 | yield* result.fold((failure) async* { 28 | yield NotLoggedState(); 29 | }, (success) async* { 30 | yield LoggedState(login: Login(token: success.token)); 31 | }); 32 | } else if (event is LoginEvent) { 33 | yield LoadingState(); 34 | final result = await loginUser( 35 | LoginParams(email: event.email, password: event.password)); 36 | yield* result.fold((failure) async* { 37 | if (failure is NoConnectionFailure) { 38 | yield ErrorState(message: NO_CONNECTION_ERROR); 39 | } else { 40 | yield ErrorState(message: LOGGING_ERROR); 41 | } 42 | }, (success) async* { 43 | yield LoggedState(login: Login(token: success.token)); 44 | }); 45 | } else if (event is SkipLoginEvent) { 46 | yield LoggedState(login: Login(token: "111111111111111111111111")); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/screens/login/presentation/blocs/user_login/user_login_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:meta/meta.dart'; 3 | 4 | @immutable 5 | abstract class UserLoginEvent extends Equatable { 6 | UserLoginEvent([List props = const []]) : super(props); 7 | } 8 | 9 | class CheckLoginStatusEvent extends UserLoginEvent {} 10 | 11 | class LoginEvent extends UserLoginEvent { 12 | final String email; 13 | final String password; 14 | 15 | LoginEvent(this.email, this.password); 16 | } 17 | 18 | class SkipLoginEvent extends UserLoginEvent {} 19 | -------------------------------------------------------------------------------- /lib/screens/login/presentation/blocs/user_login/user_login_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 3 | import 'package:meta/meta.dart'; 4 | 5 | @immutable 6 | abstract class UserLoginState extends Equatable { 7 | UserLoginState([List props = const []]) : super(props); 8 | } 9 | 10 | class NotLoggedState extends UserLoginState {} 11 | 12 | class LoadingState extends UserLoginState {} 13 | 14 | class LoggedState extends UserLoginState { 15 | final Login login; 16 | 17 | LoggedState({@required this.login}) : super([login]); 18 | } 19 | 20 | class ErrorState extends UserLoginState { 21 | final String message; 22 | 23 | ErrorState({@required this.message}) : super([message]); 24 | } 25 | -------------------------------------------------------------------------------- /lib/screens/login/presentation/page/login.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/utils/theme.dart'; 7 | import 'package:clean_architecture_with_bloc_app/core/widgets/custom_snak_bar.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/login/presentation/blocs/user_login/bloc.dart'; 9 | 10 | import '../../../../injection_container.dart'; 11 | 12 | class LoginPage extends StatefulWidget { 13 | @override 14 | State createState() => _LoginPageState(); 15 | } 16 | 17 | class _LoginPageState extends State { 18 | final TextEditingController _emailEditingController = TextEditingController(); 19 | final TextEditingController _passwordEditingController = 20 | TextEditingController(); 21 | 22 | final FocusNode _emailNode = FocusNode(); 23 | final FocusNode _passwordNode = FocusNode(); 24 | final FocusNode _viewNode = FocusNode(); 25 | 26 | final _scaffoldKey = GlobalKey(); 27 | 28 | CustomSnackBar _snackBar; 29 | bool _obscureText; 30 | 31 | @override 32 | void initState() { 33 | super.initState(); 34 | _obscureText = true; 35 | } 36 | 37 | @override 38 | void dispose() { 39 | _emailNode?.dispose(); 40 | _passwordNode?.dispose(); 41 | _viewNode?.dispose(); 42 | _emailEditingController.dispose(); 43 | _passwordEditingController.dispose(); 44 | super.dispose(); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) { 49 | _snackBar = CustomSnackBar(key: Key("snackbar"), scaffoldKey: _scaffoldKey); 50 | return GestureDetector( 51 | onTap: () => FocusScope.of(context).requestFocus(_viewNode), 52 | child: Scaffold( 53 | key: _scaffoldKey, 54 | body: AnnotatedRegion( 55 | value: SystemUiOverlayStyle.dark.copyWith( 56 | statusBarColor: CustomColor.statusBarColor, 57 | ), 58 | child: _buildBody(context), 59 | ), 60 | ), 61 | ); 62 | } 63 | 64 | BlocProvider _buildBody(BuildContext context) { 65 | final Size size = MediaQuery.of(context).size; 66 | final bool isKeyboardOpen = (MediaQuery.of(context).viewInsets.bottom > 0); 67 | return BlocProvider( 68 | create: (_) => sl(), 69 | child: Container( 70 | height: size.height, 71 | width: size.width, 72 | padding: EdgeInsets.all(DEFAULT_PAGE_PADDING), 73 | child: SingleChildScrollView( 74 | child: Column( 75 | crossAxisAlignment: CrossAxisAlignment.center, 76 | mainAxisAlignment: MainAxisAlignment.start, 77 | children: [ 78 | _buildHeader(isKeyboardOpen), 79 | _buildEmailField(context), 80 | Padding( 81 | padding: EdgeInsets.only(top: 12), 82 | ), 83 | _buildPasswordField(context), 84 | Padding( 85 | padding: EdgeInsets.only(top: 14), 86 | ), 87 | Container( 88 | width: double.infinity, 89 | height: 36, 90 | child: _buildLoginButton(), 91 | ), 92 | Padding( 93 | padding: EdgeInsets.only(top: 14), 94 | ), 95 | Container( 96 | width: double.infinity, 97 | height: 36, 98 | child: _buildSkipLoginButton(), 99 | ), 100 | ], 101 | ), 102 | ), 103 | ), 104 | ); 105 | } 106 | 107 | Widget _buildHeader(bool isKeyboardOpen) { 108 | if (!isKeyboardOpen) { 109 | return Column( 110 | children: [ 111 | Padding( 112 | padding: EdgeInsets.only(top: 74), 113 | ), 114 | SizedBox( 115 | width: 60, 116 | height: 60, 117 | child: Image( 118 | image: AssetImage("images/logo.png"), 119 | ), 120 | ), 121 | Padding( 122 | padding: EdgeInsets.only(top: 20), 123 | ), 124 | Text( 125 | "Login", 126 | style: CustomTheme.mainTheme.textTheme.title, 127 | ), 128 | Padding( 129 | padding: EdgeInsets.only(top: 14), 130 | ), 131 | ], 132 | ); 133 | } 134 | return Padding( 135 | padding: EdgeInsets.only(top: 74), 136 | ); 137 | } 138 | 139 | BlocBuilder _buildLoginButton() { 140 | return BlocBuilder( 141 | condition: (prevState, currState) { 142 | if (currState is LoggedState) { 143 | _snackBar.hideAll(); 144 | Navigator.pushNamedAndRemoveUntil(context, HOME_ROUTE, (r) => false); 145 | } 146 | return !(currState is LoggedState); 147 | }, 148 | builder: (context, state) { 149 | if (state is NotLoggedState || state is ErrorState) { 150 | if (state is ErrorState) { 151 | WidgetsBinding.instance.addPostFrameCallback((_) { 152 | _snackBar.hideAll(); 153 | _snackBar.showErrorSnackBar(state.message); 154 | }); 155 | } 156 | return RaisedButton( 157 | key: Key("login"), 158 | shape: RoundedRectangleBorder( 159 | borderRadius: new BorderRadius.circular(4.0), 160 | ), 161 | color: CustomColor.logoBlue, 162 | onPressed: () { 163 | BlocProvider.of(context).add( 164 | LoginEvent( 165 | _emailEditingController.text, 166 | _passwordEditingController.text, 167 | ), 168 | ); 169 | }, 170 | child: Text( 171 | "LOGIN", 172 | style: CustomTheme.mainTheme.textTheme.button, 173 | ), 174 | ); 175 | } else if (state is LoadingState) { 176 | WidgetsBinding.instance.addPostFrameCallback((_) { 177 | _snackBar.hideAll(); 178 | _snackBar.showLoadingSnackBar(); 179 | }); 180 | return Container(); 181 | } 182 | return Container(); 183 | }, 184 | ); 185 | } 186 | 187 | BlocBuilder _buildSkipLoginButton() { 188 | return BlocBuilder( 189 | condition: (prevState, currState) { 190 | if (currState is LoggedState) { 191 | _snackBar.hideAll(); 192 | Navigator.pushNamedAndRemoveUntil(context, HOME_ROUTE, (r) => false); 193 | } 194 | return !(currState is LoggedState); 195 | }, 196 | builder: (context, state) { 197 | if (state is NotLoggedState || state is ErrorState) { 198 | if (state is ErrorState) { 199 | WidgetsBinding.instance.addPostFrameCallback((_) { 200 | _snackBar.hideAll(); 201 | _snackBar.showErrorSnackBar(state.message); 202 | }); 203 | } 204 | return RaisedButton( 205 | key: Key("skipLogin"), 206 | shape: RoundedRectangleBorder( 207 | borderRadius: new BorderRadius.circular(4.0), 208 | ), 209 | color: CustomColor.logoBlue, 210 | onPressed: () { 211 | BlocProvider.of(context).add( 212 | SkipLoginEvent(), 213 | ); 214 | }, 215 | child: Text( 216 | "SKIP LOGIN", 217 | style: CustomTheme.mainTheme.textTheme.button, 218 | ), 219 | ); 220 | } else if (state is LoadingState) { 221 | WidgetsBinding.instance.addPostFrameCallback((_) { 222 | _snackBar.hideAll(); 223 | _snackBar.showLoadingSnackBar(); 224 | }); 225 | return Container(); 226 | } 227 | return Container(); 228 | }, 229 | ); 230 | } 231 | 232 | TextFormField _buildEmailField(BuildContext context) { 233 | return TextFormField( 234 | focusNode: _emailNode, 235 | controller: _emailEditingController, 236 | keyboardType: TextInputType.emailAddress, 237 | decoration: InputDecoration( 238 | focusedBorder: new OutlineInputBorder( 239 | borderRadius: new BorderRadius.circular(4.0), 240 | borderSide: new BorderSide( 241 | color: CustomColor.textFieldBackground, 242 | ), 243 | ), 244 | border: new OutlineInputBorder( 245 | borderRadius: new BorderRadius.circular(4.0), 246 | borderSide: new BorderSide( 247 | color: CustomColor.textFieldBackground, 248 | ), 249 | ), 250 | enabledBorder: new OutlineInputBorder( 251 | borderRadius: new BorderRadius.circular(4.0), 252 | borderSide: new BorderSide( 253 | color: CustomColor.textFieldBackground, 254 | ), 255 | ), 256 | focusColor: CustomColor.hintColor, 257 | hoverColor: CustomColor.hintColor, 258 | fillColor: CustomColor.textFieldBackground, 259 | filled: true, 260 | labelText: "Email*", 261 | labelStyle: CustomTheme.mainTheme.textTheme.body2, 262 | ), 263 | cursorColor: CustomColor.hintColor, 264 | onFieldSubmitted: (term) { 265 | _fieldFocusChange(context, _emailNode, _passwordNode); 266 | }, 267 | ); 268 | } 269 | 270 | TextFormField _buildPasswordField(BuildContext context) { 271 | return TextFormField( 272 | focusNode: _passwordNode, 273 | controller: _passwordEditingController, 274 | obscureText: _obscureText, 275 | keyboardType: TextInputType.visiblePassword, 276 | decoration: InputDecoration( 277 | focusedBorder: new OutlineInputBorder( 278 | borderRadius: new BorderRadius.circular(4.0), 279 | borderSide: new BorderSide( 280 | color: CustomColor.textFieldBackground, 281 | ), 282 | ), 283 | border: new OutlineInputBorder( 284 | borderRadius: new BorderRadius.circular(4.0), 285 | borderSide: new BorderSide( 286 | color: CustomColor.textFieldBackground, 287 | ), 288 | ), 289 | enabledBorder: new OutlineInputBorder( 290 | borderRadius: new BorderRadius.circular(4.0), 291 | borderSide: new BorderSide( 292 | color: CustomColor.textFieldBackground, 293 | ), 294 | ), 295 | focusColor: CustomColor.hintColor, 296 | hoverColor: CustomColor.hintColor, 297 | fillColor: CustomColor.textFieldBackground, 298 | filled: true, 299 | labelText: "Password*", 300 | labelStyle: CustomTheme.mainTheme.textTheme.body2, 301 | suffixIcon: IconButton( 302 | icon: Icon(Icons.remove_red_eye), 303 | color: CustomColor.hintColor, 304 | onPressed: () { 305 | setState(() { 306 | _obscureText = !_obscureText; 307 | }); 308 | }, 309 | ), 310 | ), 311 | cursorColor: CustomColor.hintColor, 312 | ); 313 | } 314 | 315 | _fieldFocusChange( 316 | BuildContext context, FocusNode currentFocus, FocusNode nextFocus) { 317 | currentFocus.unfocus(); 318 | FocusScope.of(context).requestFocus(nextFocus); 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "1.0.3" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "0.39.4" 18 | archive: 19 | dependency: transitive 20 | description: 21 | name: archive 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "2.0.11" 25 | args: 26 | dependency: transitive 27 | description: 28 | name: args 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.5.2" 32 | async: 33 | dependency: transitive 34 | description: 35 | name: async 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "2.4.0" 39 | bloc: 40 | dependency: transitive 41 | description: 42 | name: bloc 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "3.0.0" 46 | bloc_test: 47 | dependency: "direct dev" 48 | description: 49 | name: bloc_test 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "4.0.0" 53 | boolean_selector: 54 | dependency: transitive 55 | description: 56 | name: boolean_selector 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.0.5" 60 | build: 61 | dependency: transitive 62 | description: 63 | name: build 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.2.2" 67 | build_config: 68 | dependency: transitive 69 | description: 70 | name: build_config 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "0.4.2" 74 | build_daemon: 75 | dependency: transitive 76 | description: 77 | name: build_daemon 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "2.1.3" 81 | build_resolvers: 82 | dependency: transitive 83 | description: 84 | name: build_resolvers 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "1.3.3" 88 | build_runner: 89 | dependency: "direct dev" 90 | description: 91 | name: build_runner 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "1.7.4" 95 | build_runner_core: 96 | dependency: transitive 97 | description: 98 | name: build_runner_core 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "4.4.0" 102 | built_collection: 103 | dependency: transitive 104 | description: 105 | name: built_collection 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "4.3.2" 109 | built_value: 110 | dependency: transitive 111 | description: 112 | name: built_value 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "7.0.9" 116 | charcode: 117 | dependency: transitive 118 | description: 119 | name: charcode 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "1.1.2" 123 | checked_yaml: 124 | dependency: transitive 125 | description: 126 | name: checked_yaml 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "1.0.2" 130 | chopper: 131 | dependency: "direct main" 132 | description: 133 | name: chopper 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "3.0.1+1" 137 | chopper_generator: 138 | dependency: "direct dev" 139 | description: 140 | name: chopper_generator 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "3.0.0" 144 | code_builder: 145 | dependency: transitive 146 | description: 147 | name: code_builder 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "3.2.1" 151 | collection: 152 | dependency: transitive 153 | description: 154 | name: collection 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "1.14.11" 158 | convert: 159 | dependency: transitive 160 | description: 161 | name: convert 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "2.1.1" 165 | coverage: 166 | dependency: transitive 167 | description: 168 | name: coverage 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "0.13.7" 172 | crypto: 173 | dependency: transitive 174 | description: 175 | name: crypto 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "2.1.3" 179 | csslib: 180 | dependency: transitive 181 | description: 182 | name: csslib 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "0.16.1" 186 | cupertino_icons: 187 | dependency: "direct main" 188 | description: 189 | name: cupertino_icons 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "0.1.3" 193 | dart_style: 194 | dependency: transitive 195 | description: 196 | name: dart_style 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "1.3.3" 200 | dartz: 201 | dependency: "direct main" 202 | description: 203 | name: dartz 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "0.8.9" 207 | data_connection_checker: 208 | dependency: "direct main" 209 | description: 210 | name: data_connection_checker 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "0.3.4" 214 | equatable: 215 | dependency: "direct main" 216 | description: 217 | name: equatable 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "0.4.0" 221 | file: 222 | dependency: transitive 223 | description: 224 | name: file 225 | url: "https://pub.dartlang.org" 226 | source: hosted 227 | version: "5.1.0" 228 | fixnum: 229 | dependency: transitive 230 | description: 231 | name: fixnum 232 | url: "https://pub.dartlang.org" 233 | source: hosted 234 | version: "0.10.11" 235 | flutter: 236 | dependency: "direct main" 237 | description: flutter 238 | source: sdk 239 | version: "0.0.0" 240 | flutter_bloc: 241 | dependency: "direct main" 242 | description: 243 | name: flutter_bloc 244 | url: "https://pub.dartlang.org" 245 | source: hosted 246 | version: "3.2.0" 247 | flutter_driver: 248 | dependency: "direct dev" 249 | description: flutter 250 | source: sdk 251 | version: "0.0.0" 252 | flutter_test: 253 | dependency: "direct dev" 254 | description: flutter 255 | source: sdk 256 | version: "0.0.0" 257 | flutter_web_plugins: 258 | dependency: transitive 259 | description: flutter 260 | source: sdk 261 | version: "0.0.0" 262 | fuchsia_remote_debug_protocol: 263 | dependency: transitive 264 | description: flutter 265 | source: sdk 266 | version: "0.0.0" 267 | get_it: 268 | dependency: "direct main" 269 | description: 270 | name: get_it 271 | url: "https://pub.dartlang.org" 272 | source: hosted 273 | version: "2.1.0" 274 | glob: 275 | dependency: transitive 276 | description: 277 | name: glob 278 | url: "https://pub.dartlang.org" 279 | source: hosted 280 | version: "1.2.0" 281 | graphs: 282 | dependency: transitive 283 | description: 284 | name: graphs 285 | url: "https://pub.dartlang.org" 286 | source: hosted 287 | version: "0.2.0" 288 | html: 289 | dependency: transitive 290 | description: 291 | name: html 292 | url: "https://pub.dartlang.org" 293 | source: hosted 294 | version: "0.14.0+3" 295 | http: 296 | dependency: "direct main" 297 | description: 298 | name: http 299 | url: "https://pub.dartlang.org" 300 | source: hosted 301 | version: "0.12.0+4" 302 | http_multi_server: 303 | dependency: transitive 304 | description: 305 | name: http_multi_server 306 | url: "https://pub.dartlang.org" 307 | source: hosted 308 | version: "2.2.0" 309 | http_parser: 310 | dependency: transitive 311 | description: 312 | name: http_parser 313 | url: "https://pub.dartlang.org" 314 | source: hosted 315 | version: "3.1.3" 316 | image: 317 | dependency: transitive 318 | description: 319 | name: image 320 | url: "https://pub.dartlang.org" 321 | source: hosted 322 | version: "2.1.4" 323 | intl: 324 | dependency: transitive 325 | description: 326 | name: intl 327 | url: "https://pub.dartlang.org" 328 | source: hosted 329 | version: "0.16.0" 330 | io: 331 | dependency: transitive 332 | description: 333 | name: io 334 | url: "https://pub.dartlang.org" 335 | source: hosted 336 | version: "0.3.3" 337 | js: 338 | dependency: transitive 339 | description: 340 | name: js 341 | url: "https://pub.dartlang.org" 342 | source: hosted 343 | version: "0.6.1+1" 344 | json_annotation: 345 | dependency: "direct main" 346 | description: 347 | name: json_annotation 348 | url: "https://pub.dartlang.org" 349 | source: hosted 350 | version: "3.0.1" 351 | json_rpc_2: 352 | dependency: transitive 353 | description: 354 | name: json_rpc_2 355 | url: "https://pub.dartlang.org" 356 | source: hosted 357 | version: "2.1.0" 358 | json_serializable: 359 | dependency: "direct dev" 360 | description: 361 | name: json_serializable 362 | url: "https://pub.dartlang.org" 363 | source: hosted 364 | version: "3.2.5" 365 | logging: 366 | dependency: transitive 367 | description: 368 | name: logging 369 | url: "https://pub.dartlang.org" 370 | source: hosted 371 | version: "0.11.4" 372 | matcher: 373 | dependency: transitive 374 | description: 375 | name: matcher 376 | url: "https://pub.dartlang.org" 377 | source: hosted 378 | version: "0.12.6" 379 | meta: 380 | dependency: transitive 381 | description: 382 | name: meta 383 | url: "https://pub.dartlang.org" 384 | source: hosted 385 | version: "1.1.8" 386 | mime: 387 | dependency: transitive 388 | description: 389 | name: mime 390 | url: "https://pub.dartlang.org" 391 | source: hosted 392 | version: "0.9.6+3" 393 | mockito: 394 | dependency: "direct dev" 395 | description: 396 | name: mockito 397 | url: "https://pub.dartlang.org" 398 | source: hosted 399 | version: "4.1.1" 400 | multi_server_socket: 401 | dependency: transitive 402 | description: 403 | name: multi_server_socket 404 | url: "https://pub.dartlang.org" 405 | source: hosted 406 | version: "1.0.2" 407 | nested: 408 | dependency: transitive 409 | description: 410 | name: nested 411 | url: "https://pub.dartlang.org" 412 | source: hosted 413 | version: "0.0.4" 414 | node_interop: 415 | dependency: transitive 416 | description: 417 | name: node_interop 418 | url: "https://pub.dartlang.org" 419 | source: hosted 420 | version: "1.0.3" 421 | node_io: 422 | dependency: transitive 423 | description: 424 | name: node_io 425 | url: "https://pub.dartlang.org" 426 | source: hosted 427 | version: "1.0.1+2" 428 | node_preamble: 429 | dependency: transitive 430 | description: 431 | name: node_preamble 432 | url: "https://pub.dartlang.org" 433 | source: hosted 434 | version: "1.4.8" 435 | package_config: 436 | dependency: transitive 437 | description: 438 | name: package_config 439 | url: "https://pub.dartlang.org" 440 | source: hosted 441 | version: "1.1.0" 442 | package_resolver: 443 | dependency: transitive 444 | description: 445 | name: package_resolver 446 | url: "https://pub.dartlang.org" 447 | source: hosted 448 | version: "1.0.10" 449 | path: 450 | dependency: transitive 451 | description: 452 | name: path 453 | url: "https://pub.dartlang.org" 454 | source: hosted 455 | version: "1.6.4" 456 | pedantic: 457 | dependency: transitive 458 | description: 459 | name: pedantic 460 | url: "https://pub.dartlang.org" 461 | source: hosted 462 | version: "1.8.0+1" 463 | petitparser: 464 | dependency: transitive 465 | description: 466 | name: petitparser 467 | url: "https://pub.dartlang.org" 468 | source: hosted 469 | version: "2.4.0" 470 | platform: 471 | dependency: transitive 472 | description: 473 | name: platform 474 | url: "https://pub.dartlang.org" 475 | source: hosted 476 | version: "2.2.1" 477 | pool: 478 | dependency: transitive 479 | description: 480 | name: pool 481 | url: "https://pub.dartlang.org" 482 | source: hosted 483 | version: "1.4.0" 484 | process: 485 | dependency: transitive 486 | description: 487 | name: process 488 | url: "https://pub.dartlang.org" 489 | source: hosted 490 | version: "3.0.12" 491 | provider: 492 | dependency: transitive 493 | description: 494 | name: provider 495 | url: "https://pub.dartlang.org" 496 | source: hosted 497 | version: "4.0.4" 498 | pub_semver: 499 | dependency: transitive 500 | description: 501 | name: pub_semver 502 | url: "https://pub.dartlang.org" 503 | source: hosted 504 | version: "1.4.2" 505 | pubspec_parse: 506 | dependency: transitive 507 | description: 508 | name: pubspec_parse 509 | url: "https://pub.dartlang.org" 510 | source: hosted 511 | version: "0.1.5" 512 | quiver: 513 | dependency: transitive 514 | description: 515 | name: quiver 516 | url: "https://pub.dartlang.org" 517 | source: hosted 518 | version: "2.0.5" 519 | rxdart: 520 | dependency: transitive 521 | description: 522 | name: rxdart 523 | url: "https://pub.dartlang.org" 524 | source: hosted 525 | version: "0.23.1" 526 | shared_preferences: 527 | dependency: "direct main" 528 | description: 529 | name: shared_preferences 530 | url: "https://pub.dartlang.org" 531 | source: hosted 532 | version: "0.5.6+1" 533 | shared_preferences_macos: 534 | dependency: transitive 535 | description: 536 | name: shared_preferences_macos 537 | url: "https://pub.dartlang.org" 538 | source: hosted 539 | version: "0.0.1+4" 540 | shared_preferences_platform_interface: 541 | dependency: transitive 542 | description: 543 | name: shared_preferences_platform_interface 544 | url: "https://pub.dartlang.org" 545 | source: hosted 546 | version: "1.0.1" 547 | shared_preferences_web: 548 | dependency: transitive 549 | description: 550 | name: shared_preferences_web 551 | url: "https://pub.dartlang.org" 552 | source: hosted 553 | version: "0.1.2+3" 554 | shelf: 555 | dependency: transitive 556 | description: 557 | name: shelf 558 | url: "https://pub.dartlang.org" 559 | source: hosted 560 | version: "0.7.5" 561 | shelf_packages_handler: 562 | dependency: transitive 563 | description: 564 | name: shelf_packages_handler 565 | url: "https://pub.dartlang.org" 566 | source: hosted 567 | version: "1.0.4" 568 | shelf_static: 569 | dependency: transitive 570 | description: 571 | name: shelf_static 572 | url: "https://pub.dartlang.org" 573 | source: hosted 574 | version: "0.2.8" 575 | shelf_web_socket: 576 | dependency: transitive 577 | description: 578 | name: shelf_web_socket 579 | url: "https://pub.dartlang.org" 580 | source: hosted 581 | version: "0.2.3" 582 | sky_engine: 583 | dependency: transitive 584 | description: flutter 585 | source: sdk 586 | version: "0.0.99" 587 | source_gen: 588 | dependency: transitive 589 | description: 590 | name: source_gen 591 | url: "https://pub.dartlang.org" 592 | source: hosted 593 | version: "0.9.4+7" 594 | source_map_stack_trace: 595 | dependency: transitive 596 | description: 597 | name: source_map_stack_trace 598 | url: "https://pub.dartlang.org" 599 | source: hosted 600 | version: "1.1.5" 601 | source_maps: 602 | dependency: transitive 603 | description: 604 | name: source_maps 605 | url: "https://pub.dartlang.org" 606 | source: hosted 607 | version: "0.10.9" 608 | source_span: 609 | dependency: transitive 610 | description: 611 | name: source_span 612 | url: "https://pub.dartlang.org" 613 | source: hosted 614 | version: "1.5.5" 615 | splashscreen: 616 | dependency: "direct main" 617 | description: 618 | name: splashscreen 619 | url: "https://pub.dartlang.org" 620 | source: hosted 621 | version: "1.2.0" 622 | stack_trace: 623 | dependency: transitive 624 | description: 625 | name: stack_trace 626 | url: "https://pub.dartlang.org" 627 | source: hosted 628 | version: "1.9.3" 629 | stream_channel: 630 | dependency: transitive 631 | description: 632 | name: stream_channel 633 | url: "https://pub.dartlang.org" 634 | source: hosted 635 | version: "2.0.0" 636 | stream_transform: 637 | dependency: transitive 638 | description: 639 | name: stream_transform 640 | url: "https://pub.dartlang.org" 641 | source: hosted 642 | version: "1.1.0" 643 | string_scanner: 644 | dependency: transitive 645 | description: 646 | name: string_scanner 647 | url: "https://pub.dartlang.org" 648 | source: hosted 649 | version: "1.0.5" 650 | term_glyph: 651 | dependency: transitive 652 | description: 653 | name: term_glyph 654 | url: "https://pub.dartlang.org" 655 | source: hosted 656 | version: "1.1.0" 657 | test: 658 | dependency: "direct dev" 659 | description: 660 | name: test 661 | url: "https://pub.dartlang.org" 662 | source: hosted 663 | version: "1.9.4" 664 | test_api: 665 | dependency: transitive 666 | description: 667 | name: test_api 668 | url: "https://pub.dartlang.org" 669 | source: hosted 670 | version: "0.2.11" 671 | test_core: 672 | dependency: transitive 673 | description: 674 | name: test_core 675 | url: "https://pub.dartlang.org" 676 | source: hosted 677 | version: "0.2.15" 678 | timing: 679 | dependency: transitive 680 | description: 681 | name: timing 682 | url: "https://pub.dartlang.org" 683 | source: hosted 684 | version: "0.1.1+2" 685 | typed_data: 686 | dependency: transitive 687 | description: 688 | name: typed_data 689 | url: "https://pub.dartlang.org" 690 | source: hosted 691 | version: "1.1.6" 692 | vector_math: 693 | dependency: transitive 694 | description: 695 | name: vector_math 696 | url: "https://pub.dartlang.org" 697 | source: hosted 698 | version: "2.0.8" 699 | vm_service: 700 | dependency: transitive 701 | description: 702 | name: vm_service 703 | url: "https://pub.dartlang.org" 704 | source: hosted 705 | version: "2.3.1" 706 | vm_service_client: 707 | dependency: transitive 708 | description: 709 | name: vm_service_client 710 | url: "https://pub.dartlang.org" 711 | source: hosted 712 | version: "0.2.6+2" 713 | watcher: 714 | dependency: transitive 715 | description: 716 | name: watcher 717 | url: "https://pub.dartlang.org" 718 | source: hosted 719 | version: "0.9.7+13" 720 | web_socket_channel: 721 | dependency: transitive 722 | description: 723 | name: web_socket_channel 724 | url: "https://pub.dartlang.org" 725 | source: hosted 726 | version: "1.1.0" 727 | xml: 728 | dependency: transitive 729 | description: 730 | name: xml 731 | url: "https://pub.dartlang.org" 732 | source: hosted 733 | version: "3.5.0" 734 | yaml: 735 | dependency: transitive 736 | description: 737 | name: yaml 738 | url: "https://pub.dartlang.org" 739 | source: hosted 740 | version: "2.2.0" 741 | sdks: 742 | dart: ">=2.6.0 <3.0.0" 743 | flutter: ">=1.12.13+hotfix.4 <2.0.0" 744 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: clean_architecture_with_bloc_app 2 | description: A new Flutter application. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 1.0.0+1 15 | 16 | environment: 17 | sdk: ">=2.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | 23 | # Use with the CupertinoIcons class for iOS style icons. 24 | cupertino_icons: ^0.1.2 25 | # Service locator 26 | get_it: ^2.0.1 27 | # Bloc for state management 28 | flutter_bloc: ^3.2.0 29 | # Value equality 30 | equatable: ^0.4.0 31 | # Functional programming thingies 32 | dartz: ^0.8.6 33 | # Remote API 34 | data_connection_checker: ^0.3.4 35 | # Http calls 36 | http: ^0.12.0+2 37 | # Local cache 38 | shared_preferences: ^0.5.3+4 39 | # Json annotator 40 | json_annotation: ^3.0.1 41 | # API manager 42 | chopper: ^3.0.1+1 43 | #splash screen 44 | splashscreen: 1.2.0 45 | 46 | dev_dependencies: 47 | flutter_test: 48 | sdk: flutter 49 | # For testing. 50 | mockito: ^4.1.0 51 | # Code generator 52 | build_runner: ^1.7.3 53 | # Code generator from models (to json and from json) 54 | json_serializable: ^3.2.5 55 | # API code generator 56 | chopper_generator: ^3.0.0 57 | #Integration tests 58 | flutter_driver: 59 | sdk: flutter 60 | test: any 61 | #bloc testing 62 | bloc_test: ^4.0.0 63 | 64 | 65 | # For information on the generic Dart part of this file, see the 66 | # following page: https://dart.dev/tools/pub/pubspec 67 | 68 | # The following section is specific to Flutter. 69 | flutter: 70 | 71 | # The following line ensures that the Material Icons font is 72 | # included with your application, so that you can use the icons in 73 | # the material Icons class. 74 | uses-material-design: true 75 | 76 | assets: 77 | - images/logo.png 78 | 79 | fonts: 80 | - family: Roboto 81 | fonts: 82 | - asset: fonts/Roboto-Regular.ttf 83 | - asset: fonts/Roboto-Bold.ttf 84 | 85 | # To add assets to your application, add an assets section, like this: 86 | # assets: 87 | # - images/a_dot_burr.jpeg 88 | # - images/a_dot_ham.jpeg 89 | 90 | # An image asset can refer to one or more resolution-specific "variants", see 91 | # https://flutter.dev/assets-and-images/#resolution-aware. 92 | 93 | # For details regarding adding assets from package dependencies, see 94 | # https://flutter.dev/assets-and-images/#from-packages 95 | 96 | # To add custom fonts to your application, add a fonts section here, 97 | # in this "flutter" section. Each entry in this list should have a 98 | # "family" key with the font family name, and a "fonts" key with a 99 | # list giving the asset and other descriptors for the font. For 100 | # example: 101 | # fonts: 102 | # - family: Schyler 103 | # fonts: 104 | # - asset: fonts/Schyler-Regular.ttf 105 | # - asset: fonts/Schyler-Italic.ttf 106 | # style: italic 107 | # - family: Trajan Pro 108 | # fonts: 109 | # - asset: fonts/TrajanPro.ttf 110 | # - asset: fonts/TrajanPro_Bold.ttf 111 | # weight: 700 112 | # 113 | # For details regarding fonts from package dependencies, 114 | # see https://flutter.dev/custom-fonts/#from-packages 115 | -------------------------------------------------------------------------------- /test/core/network/network_info_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_connection_checker/data_connection_checker.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 4 | import 'package:mockito/mockito.dart'; 5 | 6 | class MockDataConnectionChecker extends Mock implements DataConnectionChecker {} 7 | 8 | void main() { 9 | NetworkInfoImpl networkInfoImpl; 10 | MockDataConnectionChecker mockDataConnectionChecker; 11 | 12 | setUp(() { 13 | mockDataConnectionChecker = MockDataConnectionChecker(); 14 | networkInfoImpl = 15 | NetworkInfoImpl(dataConnectionChecker: mockDataConnectionChecker); 16 | }); 17 | 18 | group('is Connected', (){ 19 | setUp((){ 20 | when(mockDataConnectionChecker.hasConnection).thenAnswer((_) async => true); 21 | }); 22 | 23 | test('should forward the connection to the desired method', () async { 24 | //act 25 | final result = await networkInfoImpl.isConnected; 26 | 27 | //assert 28 | verify(mockDataConnectionChecker.hasConnection); 29 | expect(result, true); 30 | }); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/core/usecases/fetch_token_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/usecases/fetch_token.dart'; 3 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/repositories/login_repository.dart'; 5 | import 'package:dartz/dartz.dart'; 6 | import 'package:flutter_test/flutter_test.dart'; 7 | import 'package:mockito/mockito.dart'; 8 | 9 | class MockUserRepository extends Mock implements LoginRepository {} 10 | 11 | void main() { 12 | MockUserRepository mockUserRepository; 13 | FetchToken useCase; 14 | 15 | setUp((){ 16 | mockUserRepository = MockUserRepository(); 17 | useCase = FetchToken(repository: mockUserRepository); 18 | }); 19 | 20 | final tToken = "123456789"; 21 | 22 | test('should return the cached token if available', () async { 23 | //arrange 24 | when(mockUserRepository.fetchCachedToken()).thenAnswer((_) async => Right(Login(token: tToken))); 25 | 26 | //act 27 | final result = await useCase(TokenParams()); 28 | 29 | //assert 30 | verify(mockUserRepository.fetchCachedToken()); 31 | verifyNoMoreInteractions(mockUserRepository); 32 | expect(result, Right(Login(token: tToken))); 33 | }); 34 | 35 | test('should ', () async { 36 | //arrange 37 | when(mockUserRepository.fetchCachedToken()).thenAnswer((_) async => Left(CacheFailure())); 38 | 39 | //act 40 | final result = await useCase(TokenParams()); 41 | 42 | //assert 43 | expect(result, Left(CacheFailure())); 44 | }); 45 | } -------------------------------------------------------------------------------- /test/fixtures/fixture_reader.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | String fixture(String name) => File('../test/fixtures/$name').readAsStringSync(); -------------------------------------------------------------------------------- /test/fixtures/user_login.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "1234" 3 | } -------------------------------------------------------------------------------- /test/fixtures/user_login_null_token.json: -------------------------------------------------------------------------------- 1 | { 2 | "noname": "eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJhdXRoLXNlcnZlciIsInN1YiI6ImRiNWY5MDI3LTUzMDktNDNmOC05OTc0LThiNjcyNWYwYjZhMyIsImp0aSI6IjYzMGEzMWM0LTI2MjMtNGIzOS04MjBiLTIzNTAzODlmNzlkZCIsImlhdCI6MTU4MTY3NTA5NywiZXhwIjoxNTg0MjY3MDk3fQ.TFujoZw4Y-_Ttvl37F5dsSH-_3KhBqhqKI5rQfAXB5bUx3CsdWjqwx2TuAQ4QGHI6LWLUmvNgdh1ZLCVUBgpR9QAQdV4Z5_ykT7ZEIzJ3kpmH5Pvc0qi-fJKXv9exSIK146ItGhZU9OYSJbgta9l9CNUpthE27x2OYyE9enaf0m6ZKc5YhxVLt9oE7ZbbLDEoCM-1j6R4acClveXEbLebgtgCH2Rp4QZMs-S7mWF9pmlL7mrzF22ob9YswNI6FPiZD6sndSl97oCaypLYJRgV_zDYddChn03hHg5dlstCGSxjJxuIrdubCCsoySx1-OBsD1pLLVJKxBR4h_iW93qtQ" 3 | } -------------------------------------------------------------------------------- /test/screens/change_password/data/datasources/change_password_remote_datasource_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:chopper/chopper.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/datasources/change_password_remote_datasource.dart'; 8 | import 'package:mockito/mockito.dart'; 9 | import 'package:http/http.dart' as http; 10 | 11 | class MockRestClientService extends Mock implements RestClientService {} 12 | 13 | void main() { 14 | MockRestClientService mockRestClientService; 15 | ChangePasswordRemoteDataSource remoteDataSource; 16 | 17 | setUp(() { 18 | mockRestClientService = MockRestClientService(); 19 | remoteDataSource = ChangePasswordRemoteDataSourceImpl( 20 | restClientService: mockRestClientService, 21 | ); 22 | }); 23 | 24 | group('changePassword', () { 25 | final String tOldPassword = "123456789"; 26 | final String tNewPassword = "987654321"; 27 | 28 | test('should return true when the task is successful', () async { 29 | //arrange 30 | when(mockRestClientService.changePassword(any)) 31 | .thenAnswer((_) async => Response(http.Response("", 204), '')); 32 | 33 | //act 34 | final result = 35 | await remoteDataSource.changePassword(tOldPassword, tNewPassword); 36 | 37 | //assert 38 | verify(mockRestClientService.changePassword(jsonEncode({ 39 | 'oldPassword': tOldPassword, 40 | 'newPassword': tNewPassword, 41 | }))); 42 | verifyNoMoreInteractions(mockRestClientService); 43 | expect(result, equals(true)); 44 | }); 45 | 46 | test('should return a server exception if it fails', () async { 47 | //arrange 48 | when(mockRestClientService.changePassword(any)) 49 | .thenThrow(ServerException()); 50 | 51 | //act 52 | final call = 53 | remoteDataSource.changePassword; 54 | 55 | //assert 56 | expect(() => call(tOldPassword, tNewPassword), throwsA(isA())); 57 | }); 58 | }); 59 | } 60 | -------------------------------------------------------------------------------- /test/screens/change_password/data/repositories/change_password_repository_impl_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/datasources/change_password_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/datasources/change_password_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/change_password/data/repositories/change_password_repository_impl.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/repositories/change_password_repository.dart'; 10 | import 'package:mockito/mockito.dart'; 11 | 12 | class MockLocalDataSource extends Mock 13 | implements ChangePasswordLocalDataSource {} 14 | 15 | class MockRemoteDataSource extends Mock 16 | implements ChangePasswordRemoteDataSource {} 17 | 18 | class MockNetworkInfo extends Mock implements NetworkInfo {} 19 | 20 | void main() { 21 | MockLocalDataSource mockLocalDataSource; 22 | MockRemoteDataSource mockRemoteDataSource; 23 | MockNetworkInfo mockNetworkInfo; 24 | ChangePasswordRepository repository; 25 | 26 | setUp(() { 27 | mockRemoteDataSource = MockRemoteDataSource(); 28 | mockLocalDataSource = MockLocalDataSource(); 29 | mockNetworkInfo = MockNetworkInfo(); 30 | repository = ChangePasswordRepositoryImpl( 31 | remoteDataSource: mockRemoteDataSource, 32 | localDataSource: mockLocalDataSource, 33 | networkInfo: mockNetworkInfo, 34 | ); 35 | }); 36 | 37 | group('changePassword', () { 38 | final String tOldPassword = "123456789"; 39 | final String tNewPassword = "987654321"; 40 | 41 | test('should return true is everything is successful', () async { 42 | //arrange 43 | when(mockNetworkInfo.isConnected) 44 | .thenAnswer((_) async => Future.value(true)); 45 | when(mockRemoteDataSource.changePassword(any, any)) 46 | .thenAnswer((_) async => Future.value(true)); 47 | 48 | //act 49 | final result = 50 | await repository.changePassword(tOldPassword, tNewPassword); 51 | 52 | //assert 53 | verify(mockNetworkInfo.isConnected); 54 | expect(result, equals(Right(true))); 55 | }); 56 | 57 | test('should return server failure if a server exception is thrown', 58 | () async { 59 | //arrange 60 | when(mockNetworkInfo.isConnected) 61 | .thenAnswer((_) async => Future.value(true)); 62 | when(mockRemoteDataSource.changePassword(any, any)) 63 | .thenThrow(ServerException()); 64 | 65 | //act 66 | final result = 67 | await repository.changePassword(tOldPassword, tNewPassword); 68 | 69 | //assert 70 | verify(mockNetworkInfo.isConnected); 71 | expect(result, equals(Left(ServerFailure()))); 72 | }); 73 | 74 | test('should return no connection failure if the device is offline', 75 | () async { 76 | //arrange 77 | when(mockNetworkInfo.isConnected) 78 | .thenAnswer((_) async => Future.value(false)); 79 | 80 | //act 81 | final result = 82 | await repository.changePassword(tOldPassword, tNewPassword); 83 | 84 | //assert 85 | verify(mockNetworkInfo.isConnected); 86 | verifyZeroInteractions(mockRemoteDataSource); 87 | expect(result, equals(Left(NoConnectionFailure()))); 88 | }); 89 | }); 90 | } 91 | -------------------------------------------------------------------------------- /test/screens/change_password/domain/usecases/change_password_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/repositories/change_password_repository.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/usecases/change_password.dart'; 6 | import 'package:mockito/mockito.dart'; 7 | 8 | class MockChangePasswordRepository extends Mock 9 | implements ChangePasswordRepository {} 10 | 11 | void main() { 12 | MockChangePasswordRepository mockRepository; 13 | ChangePassword usecase; 14 | 15 | setUp(() { 16 | mockRepository = MockChangePasswordRepository(); 17 | usecase = ChangePassword( 18 | repository: mockRepository, 19 | ); 20 | }); 21 | 22 | group('call', () { 23 | final String tOldPassword = "123456789"; 24 | final String tNewPassword = "987654321"; 25 | 26 | test('should return true if everything is successfull', () async { 27 | //arrange 28 | when(mockRepository.changePassword(any, any)) 29 | .thenAnswer((_) async => Right(true)); 30 | 31 | //act 32 | final result = await usecase(ChangePasswordParams( 33 | oldPassword: tOldPassword, 34 | newPassword: tNewPassword, 35 | )); 36 | 37 | //assert 38 | verify(mockRepository.changePassword(tOldPassword, tNewPassword)); 39 | verifyNoMoreInteractions(mockRepository); 40 | expect(result, Right(true)); 41 | }); 42 | 43 | test('should return failure if anything is wrong', () async { 44 | //arrange 45 | when(mockRepository.changePassword(any, any)) 46 | .thenAnswer((_) async => Left(ServerFailure())); 47 | 48 | //act 49 | final result = await usecase(ChangePasswordParams( 50 | oldPassword: tOldPassword, 51 | newPassword: tNewPassword, 52 | )); 53 | 54 | //assert 55 | verify(mockRepository.changePassword(tOldPassword, tNewPassword)); 56 | verifyNoMoreInteractions(mockRepository); 57 | expect(result, Left(ServerFailure())); 58 | }); 59 | }); 60 | } 61 | -------------------------------------------------------------------------------- /test/screens/change_password/presentation/blocs/change_password/change_password_bloc_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/usecases/change_password.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/change_password/presentation/blocs/change_password/bloc.dart'; 7 | import 'package:mockito/mockito.dart'; 8 | 9 | class MockChangePassword extends Mock implements ChangePassword {} 10 | 11 | void main() { 12 | MockChangePassword mockChangePassword; 13 | ChangePasswordBloc bloc; 14 | 15 | setUp(() { 16 | mockChangePassword = MockChangePassword(); 17 | bloc = ChangePasswordBloc(changePassword: mockChangePassword); 18 | }); 19 | 20 | group('initialState', () { 21 | test('should be equal to Initial State', () async { 22 | //assert 23 | expect(bloc.initialState, equals(InitialState())); 24 | }); 25 | }); 26 | 27 | group('mapEventToState', () { 28 | final String tOldPassword = "123456789"; 29 | final String tNewPassword = "987654321"; 30 | 31 | test( 32 | 'should return the correct sequence of states ' 33 | 'when everything is successfull', () async { 34 | //arrange 35 | when(mockChangePassword(any)).thenAnswer((_) async => Right(true)); 36 | 37 | //assert later 38 | expect( 39 | bloc, 40 | emitsInOrder([ 41 | InitialState(), 42 | LoadingState(), 43 | SuccessfulState(), 44 | ])); 45 | 46 | //act 47 | bloc.add(PasswordChangeEvent( 48 | oldPassword: tOldPassword, 49 | newPassword: tNewPassword, 50 | )); 51 | await untilCalled(mockChangePassword(any)); 52 | 53 | //assert 54 | verify(mockChangePassword(ChangePasswordParams( 55 | oldPassword: tOldPassword, 56 | newPassword: tNewPassword, 57 | ))); 58 | }); 59 | 60 | test( 61 | 'should return the correct sequence of states ' 62 | 'when it fails', () async { 63 | //arrange 64 | when(mockChangePassword(any)) 65 | .thenAnswer((_) async => Left(ServerFailure())); 66 | 67 | //assert later 68 | expect( 69 | bloc, 70 | emitsInOrder([ 71 | InitialState(), 72 | LoadingState(), 73 | ErrorState(CHANGE_PASSWORD_ERROR), 74 | ])); 75 | 76 | //act 77 | bloc.add(PasswordChangeEvent( 78 | oldPassword: tOldPassword, 79 | newPassword: tNewPassword, 80 | )); 81 | await untilCalled(mockChangePassword(any)); 82 | 83 | //assert 84 | verify(mockChangePassword(ChangePasswordParams( 85 | oldPassword: tOldPassword, 86 | newPassword: tNewPassword, 87 | ))); 88 | }); 89 | }); 90 | } 91 | -------------------------------------------------------------------------------- /test/screens/change_password/presentation/page/change_password_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc_test/bloc_test.dart'; 2 | import 'package:clean_architecture_with_bloc_app/injection_container.dart'; 3 | import 'package:clean_architecture_with_bloc_app/screens/change_password/domain/usecases/change_password.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/change_password/presentation/blocs/change_password/bloc.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/change_password/presentation/page/change_password.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter_test/flutter_test.dart'; 8 | import 'package:mockito/mockito.dart'; 9 | 10 | class MockChangePasswordBloc extends Mock implements ChangePasswordBloc {} 11 | 12 | class MockChangePassword extends Mock implements ChangePassword {} 13 | 14 | main() { 15 | var bloc = MockChangePasswordBloc(); 16 | final Widget testWidget = new MediaQuery( 17 | data: new MediaQueryData(), 18 | child: new MaterialApp(home: new ChangePasswordPage())); 19 | 20 | setUp(() { 21 | sl.allowReassignment = true; 22 | sl.registerSingleton(bloc); 23 | when(bloc.state).thenAnswer((_) => InitialState()); 24 | }); 25 | 26 | testWidgets('Test the initial state of the page', 27 | (WidgetTester tester) async { 28 | whenListen(bloc, Stream.fromIterable([InitialState()])); 29 | 30 | await tester.pumpWidget(testWidget); 31 | 32 | expect(find.byKey(Key('changePassword')), findsOneWidget); 33 | }); 34 | 35 | testWidgets('Tap the chage password button', 36 | (WidgetTester tester) async { 37 | whenListen(bloc, Stream.fromIterable([InitialState()])); 38 | 39 | await tester.pumpWidget(testWidget); 40 | await tester.tap(find.byKey(Key('changePassword'))); 41 | await tester.pumpAndSettle(); 42 | 43 | expect(find.byType(SnackBar), findsOneWidget); 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /test/screens/home/data/datasources/home_local_datasource_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_local_datasource.dart'; 5 | import 'package:mockito/mockito.dart'; 6 | import 'package:shared_preferences/shared_preferences.dart'; 7 | 8 | class MockSharedPreferences extends Mock implements SharedPreferences {} 9 | 10 | void main() { 11 | MockSharedPreferences mockSharedPreferences; 12 | HomeLocalDataSource localDataSource; 13 | 14 | setUp(() { 15 | mockSharedPreferences = MockSharedPreferences(); 16 | localDataSource = HomeLocalDataSourceImpl( 17 | sharedPreferences: mockSharedPreferences, 18 | ); 19 | }); 20 | 21 | group('clearToken', (){ 22 | test('should return true when removing is successful', () async { 23 | //arrange 24 | when(mockSharedPreferences.remove(any)).thenAnswer((_) => Future.value(true)); 25 | 26 | //act 27 | final result = await localDataSource.clearToken(); 28 | 29 | //assert 30 | verify(mockSharedPreferences.remove(CACHED_TOKEN)); 31 | verifyNoMoreInteractions(mockSharedPreferences); 32 | expect(result, true); 33 | }); 34 | 35 | test('should throw a cache exception when the task is not successfull', () async { 36 | //arrange 37 | when(mockSharedPreferences.remove(any)).thenThrow(CacheException()); 38 | 39 | //act 40 | final call = localDataSource.clearToken; 41 | 42 | //assert 43 | expect(() => call(), throwsA(isA())); 44 | }); 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /test/screens/home/data/datasources/home_remote_datasource_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:chopper/chopper.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:http/http.dart' as http; 6 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 7 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_remote_datasource.dart'; 9 | import 'package:mockito/mockito.dart'; 10 | 11 | class MockRestClientService extends Mock implements RestClientService {} 12 | 13 | void main() { 14 | MockRestClientService mockRestClientService; 15 | HomeRemoteDataSourceImpl dataSourceImpl; 16 | 17 | setUp(() { 18 | mockRestClientService = MockRestClientService(); 19 | dataSourceImpl = HomeRemoteDataSourceImpl( 20 | restClientService: mockRestClientService, 21 | ); 22 | }); 23 | 24 | group('logOutUser', (){ 25 | test('should log out if the response is 204', () async { 26 | //arrange 27 | when(mockRestClientService.logoutUser(any, any)).thenAnswer((_) async => Response(http.Response("", 204), '')); 28 | 29 | //act 30 | final result = await dataSourceImpl.logoutUser("1234"); 31 | 32 | //assert 33 | verify(mockRestClientService.logoutUser(jsonEncode({ 34 | 'token': "1234", 35 | }),"1234")); 36 | expect(result, true); 37 | }); 38 | 39 | test('should throw an exception if the response is not 204', () async { 40 | //arrange 41 | when(mockRestClientService.logoutUser(any, any)).thenAnswer((_) async => Response(http.Response("", 401), '')); 42 | 43 | //act 44 | final call = dataSourceImpl.logoutUser; 45 | 46 | //assert 47 | expect(() => call("1234"), throwsA(isA())); 48 | }); 49 | }); 50 | } 51 | -------------------------------------------------------------------------------- /test/screens/home/data/repositories/home_repository_impl_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/home/data/datasources/home_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/home/data/repositories/home_repository_impl.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/repositories/home_repository.dart'; 10 | import 'package:mockito/mockito.dart'; 11 | 12 | class MockLocalDataSource extends Mock implements HomeLocalDataSource {} 13 | 14 | class MockRemoteDataSource extends Mock implements HomeRemoteDataSource {} 15 | 16 | class MockNetworkInfo extends Mock implements NetworkInfo {} 17 | 18 | void main() { 19 | MockLocalDataSource mockLocalDataSource; 20 | MockRemoteDataSource mockRemoteDataSource; 21 | MockNetworkInfo mockNetworkInfo; 22 | HomeRepository repository; 23 | 24 | setUp(() { 25 | mockRemoteDataSource = MockRemoteDataSource(); 26 | mockLocalDataSource = MockLocalDataSource(); 27 | mockNetworkInfo = MockNetworkInfo(); 28 | repository = HomeRepositoryImpl( 29 | remoteDataSource: mockRemoteDataSource, 30 | localDataSource: mockLocalDataSource, 31 | networkInfo: mockNetworkInfo, 32 | ); 33 | }); 34 | 35 | group('logoutUser', (){ 36 | final String tToken = "123456789"; 37 | 38 | test('should return true if successfully logged out', () async { 39 | //arrange 40 | when(mockNetworkInfo.isConnected).thenAnswer((_) => Future.value(true)); 41 | when(mockRemoteDataSource.logoutUser(any)).thenAnswer((_) => Future.value(true)); 42 | when(mockLocalDataSource.clearToken()).thenAnswer((_) => Future.value(true)); 43 | 44 | //act 45 | final result = await repository.logoutUser(tToken); 46 | 47 | //assert 48 | verify(mockNetworkInfo.isConnected); 49 | verify(mockRemoteDataSource.logoutUser(tToken)); 50 | verify(mockLocalDataSource.clearToken()); 51 | verifyNoMoreInteractions(mockRemoteDataSource); 52 | expect(result, Right(true)); 53 | }); 54 | 55 | test('should return an cache failure if getting cached token is unsuccessful', () async { 56 | //arrange 57 | when(mockNetworkInfo.isConnected).thenAnswer((_) => Future.value(true)); 58 | when(mockRemoteDataSource.logoutUser(any)).thenAnswer((_) => Future.value(true)); 59 | when(mockLocalDataSource.clearToken()).thenThrow(CacheException()); 60 | 61 | //act 62 | final result = await repository.logoutUser(tToken); 63 | 64 | //assert 65 | verify(mockNetworkInfo.isConnected); 66 | verify(mockRemoteDataSource.logoutUser(tToken)); 67 | verify(mockLocalDataSource.clearToken()); 68 | verifyNoMoreInteractions(mockRemoteDataSource); 69 | expect(result, Left(CacheFailure())); 70 | }); 71 | 72 | test('should return a server failure if logout user is not successfull', () async { 73 | //arrange 74 | when(mockNetworkInfo.isConnected).thenAnswer((_) => Future.value(true)); 75 | when(mockRemoteDataSource.logoutUser(any)).thenThrow(ServerException()); 76 | 77 | //act 78 | final result = await repository.logoutUser(tToken); 79 | 80 | //assert 81 | verify(mockNetworkInfo.isConnected); 82 | verify(mockRemoteDataSource.logoutUser(tToken)); 83 | verifyZeroInteractions(mockLocalDataSource); 84 | verifyNoMoreInteractions(mockRemoteDataSource); 85 | expect(result, Left(ServerFailure())); 86 | }); 87 | 88 | test('should return a no connection failure if device is offline', () async { 89 | //arrange 90 | when(mockNetworkInfo.isConnected).thenAnswer((_) => Future.value(false)); 91 | 92 | //act 93 | final result = await repository.logoutUser(tToken); 94 | 95 | //assert 96 | verify(mockNetworkInfo.isConnected); 97 | verifyZeroInteractions(mockRemoteDataSource); 98 | verifyZeroInteractions(mockLocalDataSource); 99 | expect(result, Left(NoConnectionFailure())); 100 | }); 101 | }); 102 | } 103 | -------------------------------------------------------------------------------- /test/screens/home/domain/usecases/logout_user_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/repositories/home_repository.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/usecases/logout_user.dart'; 6 | import 'package:mockito/mockito.dart'; 7 | 8 | class MockHomeRepository extends Mock implements HomeRepository {} 9 | 10 | void main() { 11 | MockHomeRepository mockHomeRepository; 12 | LogOutUser logOutUser; 13 | 14 | setUp((){ 15 | mockHomeRepository = MockHomeRepository(); 16 | logOutUser = LogOutUser(repository: mockHomeRepository); 17 | }); 18 | 19 | group('call', (){ 20 | final String tToken = "123456789"; 21 | 22 | test('should return true if logging out is successfull', () async { 23 | //arrange 24 | when(mockHomeRepository.logoutUser(any)).thenAnswer((_) async => Right(true)); 25 | 26 | //act 27 | final result = await logOutUser(LogOutParams(token: tToken)); 28 | 29 | //assert 30 | verify(mockHomeRepository.logoutUser(tToken)); 31 | expect(result, Right(true)); 32 | }); 33 | 34 | test('should return a failure if logging out returns', () async { 35 | //arrange 36 | when(mockHomeRepository.logoutUser(any)).thenAnswer((_) async => Left(ServerFailure())); 37 | 38 | //act 39 | final result = await logOutUser(LogOutParams(token: tToken)); 40 | 41 | //assert 42 | verify(mockHomeRepository.logoutUser(tToken)); 43 | expect(result, Left(ServerFailure())); 44 | }); 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /test/screens/home/presentation/blocs/log_out/log_out_bloc_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/usecases/fetch_token.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/home/domain/usecases/logout_user.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/home/presentation/blocs/log_out/bloc.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 9 | import 'package:mockito/mockito.dart'; 10 | 11 | class MockLogOutUser extends Mock implements LogOutUser {} 12 | 13 | class MockFetchToken extends Mock implements FetchToken {} 14 | 15 | void main() { 16 | MockFetchToken mockFetchToken; 17 | MockLogOutUser mockLogOutUser; 18 | LogOutBloc logOutBloc; 19 | 20 | setUp(() { 21 | mockLogOutUser = MockLogOutUser(); 22 | mockFetchToken = MockFetchToken(); 23 | logOutBloc = LogOutBloc( 24 | logoutUser: mockLogOutUser, 25 | fetchToken: mockFetchToken, 26 | ); 27 | }); 28 | 29 | group('initialState', () { 30 | test('should return LoggedInState as the initial state', () async { 31 | //assert 32 | expect(logOutBloc.initialState, equals(LoggedInState())); 33 | }); 34 | }); 35 | 36 | group('mapEventToState', () { 37 | final String tToken = "123456789"; 38 | 39 | test( 40 | 'should return the correct sequence of states ' 41 | 'when everything is successfull', () async { 42 | //arrange 43 | when(mockFetchToken(any)).thenAnswer((_) async => Right(Login( 44 | token: tToken, 45 | ))); 46 | when(mockLogOutUser(any)).thenAnswer((_) async => Right(true)); 47 | 48 | //assert later 49 | expectLater( 50 | logOutBloc, 51 | emitsInOrder([ 52 | LoggedInState(), 53 | LoadingState(), 54 | LoggedOutState(), 55 | ])); 56 | 57 | //act 58 | logOutBloc.add(UserLogOutEvent()); 59 | await untilCalled(mockLogOutUser.call(any)); 60 | 61 | //assert 62 | verify(mockFetchToken.call(TokenParams())); 63 | verify(mockLogOutUser.call(LogOutParams(token: tToken))); 64 | }); 65 | 66 | test( 67 | 'should return the correct sequence of states ' 68 | 'when logoutuser is not successfull', () async { 69 | //arrange 70 | when(mockFetchToken.call(any)).thenAnswer((_) async => Right(Login( 71 | token: tToken, 72 | ))); 73 | when(mockLogOutUser.call(any)) 74 | .thenAnswer((_) async => Left(ServerFailure())); 75 | 76 | //assert later 77 | expectLater( 78 | logOutBloc, 79 | emitsInOrder([ 80 | LoggedInState(), 81 | LoadingState(), 82 | ErrorState(LOGGING_OUT_ERROR), 83 | ])); 84 | 85 | //act 86 | logOutBloc.add(UserLogOutEvent()); 87 | await untilCalled(mockLogOutUser.call(any)); 88 | 89 | //assert 90 | verify(mockFetchToken.call(TokenParams())); 91 | verify(mockLogOutUser.call(LogOutParams(token: tToken))); 92 | }); 93 | 94 | test( 95 | 'should return the correct sequence of states ' 96 | 'when fetch token is not successfull', () async { 97 | //arrange 98 | when(mockFetchToken.call(any)) 99 | .thenAnswer((_) async => Left(CacheFailure())); 100 | 101 | //assert later 102 | expectLater( 103 | logOutBloc, 104 | emitsInOrder([ 105 | LoggedInState(), 106 | LoadingState(), 107 | ErrorState(LOGGING_OUT_ERROR), 108 | ])); 109 | 110 | //act 111 | logOutBloc.add(UserLogOutEvent()); 112 | await untilCalled(mockFetchToken.call(any)); 113 | 114 | //assert 115 | verify(mockFetchToken.call(TokenParams())); 116 | verifyZeroInteractions(mockLogOutUser); 117 | }); 118 | }); 119 | } 120 | -------------------------------------------------------------------------------- /test/screens/login/data/datasources/login_local_datasource_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/data/datasources/login_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/data/models/login_model.dart'; 8 | import 'package:mockito/mockito.dart'; 9 | import 'package:shared_preferences/shared_preferences.dart'; 10 | 11 | import '../../../../fixtures/fixture_reader.dart'; 12 | 13 | class MockSharedPreferences extends Mock implements SharedPreferences {} 14 | 15 | void main() { 16 | MockSharedPreferences mockSharedPreferences; 17 | LoginLocalDataSourceImpl dataSourceImpl; 18 | 19 | setUp(() { 20 | mockSharedPreferences = MockSharedPreferences(); 21 | dataSourceImpl = 22 | LoginLocalDataSourceImpl(sharedPreferences: mockSharedPreferences); 23 | }); 24 | 25 | group('getLastToken', () { 26 | final LoginModel tLoginModel = 27 | LoginModel.fromJson(jsonDecode(fixture('user_login.json'))); 28 | 29 | test('should return last stored token (cached)', () async { 30 | //arrange 31 | when(mockSharedPreferences.getString(any)) 32 | .thenReturn(fixture('user_login.json')); 33 | 34 | //act 35 | final result = await dataSourceImpl.getLastToken(); 36 | 37 | //assert 38 | verify(mockSharedPreferences.getString(CACHED_TOKEN)); 39 | expect(result, tLoginModel); 40 | }); 41 | 42 | test('should return a Cache Failure when there is no stored token', 43 | () async { 44 | //arrange 45 | when(mockSharedPreferences.getString(any)).thenThrow(CacheException()); 46 | 47 | //act 48 | final call = dataSourceImpl.getLastToken; 49 | 50 | //assert 51 | expect(() => call(), throwsA(isA())); 52 | }); 53 | }); 54 | 55 | group('cacheToken', () { 56 | final LoginModel tLoginModel = LoginModel(token: '123456'); 57 | 58 | test('should store the token', () async { 59 | //act 60 | dataSourceImpl.cacheToken(tLoginModel); 61 | 62 | //assert 63 | verify(mockSharedPreferences.setString( 64 | CACHED_TOKEN, jsonEncode(tLoginModel))); 65 | }); 66 | }); 67 | } 68 | -------------------------------------------------------------------------------- /test/screens/login/data/datasources/login_remote_datasource_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:chopper/chopper.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/network/rest_client_service.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/data/datasources/login_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/login/data/models/login_model.dart'; 9 | import 'package:mockito/mockito.dart'; 10 | import 'package:http/http.dart' as http; 11 | 12 | import '../../../../fixtures/fixture_reader.dart'; 13 | 14 | class MockHttpClient extends Mock implements RestClientService {} 15 | 16 | void main() { 17 | MockHttpClient mockHttpClient; 18 | LoginRemoteDataSourceImpl dataSourceImpl; 19 | 20 | setUp(() { 21 | mockHttpClient = MockHttpClient(); 22 | dataSourceImpl = LoginRemoteDataSourceImpl(restClientService: mockHttpClient); 23 | }); 24 | 25 | group('loginUser', () { 26 | final String tEmail = 'test@test.com'; 27 | final String tPassword = 'test'; 28 | final LoginModel tLoginModel = LoginModel(token: '1234'); 29 | 30 | test('should return the User object if the status code is 200', 31 | () async { 32 | //arrange 33 | when(mockHttpClient.loginUser(jsonEncode({ 34 | 'email': tEmail, 35 | 'password': tPassword, 36 | }))).thenAnswer( 37 | (_) async => Response(http.Response("", 200), fixture('user_login.json'))); 38 | //act 39 | final result = await dataSourceImpl.loginUser(tEmail, tPassword); 40 | 41 | //assert 42 | verify(mockHttpClient.loginUser(jsonEncode({ 43 | 'email': tEmail, 44 | 'password': tPassword, 45 | }))); 46 | expect(result, equals(tLoginModel)); 47 | }); 48 | 49 | test('should throw an exception if the status code is not 200', () async { 50 | //arrange 51 | when(mockHttpClient.loginUser(jsonEncode({ 52 | 'email': tEmail, 53 | 'password': tPassword, 54 | }))) 55 | .thenAnswer((_) async => Response(http.Response("", 404), "Something went wrong")); 56 | 57 | //act 58 | final call = dataSourceImpl.loginUser; 59 | 60 | //assert 61 | expect(() => call(tEmail, tPassword), throwsA(isA())); 62 | }); 63 | }); 64 | } 65 | -------------------------------------------------------------------------------- /test/screens/login/data/models/login_model_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/login/data/models/login_model.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 6 | 7 | import '../../../../fixtures/fixture_reader.dart'; 8 | 9 | void main(){ 10 | LoginModel tLoginModel = LoginModel(token: "1234"); 11 | test('should be a subclass of User entity', () async { 12 | //assert 13 | expect(tLoginModel, isA()); 14 | }); 15 | 16 | group("fromJson", (){ 17 | test('should return a valid model when a valid JSON is given', () async { 18 | //arrange 19 | Map jsonMap = jsonDecode(fixture("user_login.json")); 20 | 21 | //act 22 | final result = LoginModel.fromJson(jsonMap); 23 | 24 | //assert 25 | expect(result, equals(tLoginModel)); 26 | }); 27 | 28 | test('should return a null token when a token is not given in the JSON', () async { 29 | //arrange 30 | Map jsonMap = jsonDecode(fixture("user_login_null_token.json")); 31 | 32 | //act 33 | final result = LoginModel.fromJson(jsonMap); 34 | 35 | //assert 36 | expect(result, equals(LoginModel(token: null))); 37 | }); 38 | }); 39 | 40 | group("toJson", (){ 41 | test('should return a valid map when called the toJson method', () async { 42 | //act 43 | final result = tLoginModel.toJson(); 44 | 45 | //assert 46 | final expectedMap = { 47 | 'token': '1234' 48 | }; 49 | expect(result, equals(expectedMap)); 50 | }); 51 | }); 52 | } -------------------------------------------------------------------------------- /test/screens/login/data/repositories/login_repository_impl_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/exceptions.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 5 | import 'package:clean_architecture_with_bloc_app/core/network/network_info.dart'; 6 | import 'package:clean_architecture_with_bloc_app/screens/login/data/datasources/login_local_datasource.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/data/datasources/login_remote_datasource.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/login/data/models/login_model.dart'; 9 | import 'package:clean_architecture_with_bloc_app/screens/login/data/repositories/login_repository_impl.dart'; 10 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 11 | import 'package:mockito/mockito.dart'; 12 | 13 | class MockUserRemoteDataSource extends Mock 14 | implements LoginRemoteDataSource {} 15 | 16 | class MockUserLocalDataSource extends Mock 17 | implements LoginLocalDataSource {} 18 | 19 | class MockNetworkInfo extends Mock implements NetworkInfo {} 20 | 21 | void main() { 22 | LoginRepositoryImpl repository; 23 | MockUserRemoteDataSource mockRemoteDataSource; 24 | MockUserLocalDataSource mockLocalDataSource; 25 | MockNetworkInfo mockNetworkInfo; 26 | 27 | setUp(() { 28 | mockRemoteDataSource = MockUserRemoteDataSource(); 29 | mockLocalDataSource = MockUserLocalDataSource(); 30 | mockNetworkInfo = MockNetworkInfo(); 31 | repository = LoginRepositoryImpl( 32 | networkInfo: mockNetworkInfo, 33 | localDataSource: mockLocalDataSource, 34 | remoteDataSource: mockRemoteDataSource, 35 | ); 36 | }); 37 | 38 | final String tEmail = "test@test.com"; 39 | final String tPassword = "test"; 40 | final LoginModel tLoginModel = LoginModel(token: "1234"); 41 | final Login tLogin = tLoginModel; 42 | 43 | group("get user token", () { 44 | test('should check if the device is online', () async { 45 | //arrange 46 | when(mockNetworkInfo.isConnected).thenAnswer((_) async => true); 47 | 48 | //act 49 | repository.loginUser(tEmail, tPassword); 50 | 51 | //assert 52 | verify(mockNetworkInfo.isConnected); 53 | }); 54 | }); 55 | 56 | group("device is online", () { 57 | setUp(() { 58 | when(mockNetworkInfo.isConnected).thenAnswer((_) async => true); 59 | }); 60 | 61 | test('should return the token when the remote call is successfull', () async { 62 | //arrange 63 | when(mockRemoteDataSource.loginUser(tEmail, tPassword)) 64 | .thenAnswer((_) async => tLoginModel); 65 | 66 | //act 67 | final result = await repository.loginUser(tEmail, tPassword); 68 | 69 | //assert 70 | verify(mockRemoteDataSource.loginUser(tEmail, tPassword)); 71 | expect(result, equals(Right(tLogin))); 72 | }); 73 | 74 | test('should cache the token locally when the remote call is successfull', () async { 75 | //arrange 76 | when(mockRemoteDataSource.loginUser(tEmail, tPassword)) 77 | .thenAnswer((_) async => tLoginModel); 78 | 79 | //act 80 | await repository.loginUser(tEmail, tPassword); 81 | 82 | //assert 83 | verify(mockRemoteDataSource.loginUser(tEmail, tPassword)); 84 | verify(mockLocalDataSource.cacheToken(tLoginModel)); 85 | }); 86 | 87 | test('should return a failure when the remote call is unsuccessfull', () async { 88 | //arrange 89 | when(mockRemoteDataSource.loginUser(tEmail, tPassword)) 90 | .thenThrow(ServerException()); 91 | 92 | //act 93 | final result = await repository.loginUser(tEmail, tPassword); 94 | 95 | //assert 96 | verify(mockRemoteDataSource.loginUser(tEmail, tPassword)); 97 | verifyZeroInteractions(mockLocalDataSource); 98 | expect(result, equals(Left(ServerFailure()))); 99 | }); 100 | }); 101 | 102 | group("device is offline", () { 103 | setUp(() { 104 | when(mockNetworkInfo.isConnected).thenAnswer((_) async => false); 105 | }); 106 | 107 | test('should return a NoConnectionFailure if the device is offline', () async { 108 | //arrange 109 | when(mockNetworkInfo.isConnected).thenAnswer((_) => Future.value(false)); 110 | 111 | //act 112 | final result = await repository.loginUser(tEmail, tPassword); 113 | 114 | //assert 115 | verifyZeroInteractions(mockRemoteDataSource); 116 | expect(result, equals(Left(NoConnectionFailure()))); 117 | }); 118 | }); 119 | } 120 | -------------------------------------------------------------------------------- /test/screens/login/domain/usecases/login_user_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 4 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/repositories/login_repository.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/usecases/login_user.dart'; 6 | import 'package:mockito/mockito.dart'; 7 | 8 | class MockUserRepository extends Mock implements LoginRepository {} 9 | 10 | void main() { 11 | MockUserRepository mockUserRepository; 12 | LoginUser useCase; 13 | 14 | setUp((){ 15 | mockUserRepository = MockUserRepository(); 16 | useCase = LoginUser(repository: mockUserRepository); 17 | }); 18 | 19 | final tEmail = "test@test.com"; 20 | final Login tUser = Login(token: ""); 21 | 22 | test('should return a User object with relevant email and token', () async { 23 | //arrange 24 | when(mockUserRepository.loginUser(tEmail, "test")).thenAnswer((_) async => Right(tUser)); 25 | 26 | //act 27 | final result = await useCase(LoginParams(email: tEmail, password: "test")); 28 | 29 | //assert 30 | expect(result, Right(tUser)); 31 | verify(mockUserRepository.loginUser(tEmail, "test")); 32 | verifyNoMoreInteractions(mockUserRepository); 33 | }); 34 | } -------------------------------------------------------------------------------- /test/screens/login/presentation/blocs/user_login/user_login_bloc_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:clean_architecture_with_bloc_app/core/error/failures.dart'; 4 | import 'package:clean_architecture_with_bloc_app/core/utils/constants.dart'; 5 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/entities/login.dart'; 6 | import 'package:clean_architecture_with_bloc_app/core/usecases/fetch_token.dart'; 7 | import 'package:clean_architecture_with_bloc_app/screens/login/domain/usecases/login_user.dart'; 8 | import 'package:clean_architecture_with_bloc_app/screens/login/presentation/blocs/user_login/bloc.dart'; 9 | import 'package:mockito/mockito.dart'; 10 | 11 | class MockLoginUser extends Mock implements LoginUser {} 12 | 13 | class MockFetchToken extends Mock implements FetchToken {} 14 | 15 | void main() { 16 | UserLoginBloc userLoginBloc; 17 | MockLoginUser mockLoginUser; 18 | MockFetchToken mockFetchToken; 19 | 20 | setUp(() { 21 | mockLoginUser = MockLoginUser(); 22 | mockFetchToken = MockFetchToken(); 23 | userLoginBloc = UserLoginBloc( 24 | loginUser: mockLoginUser, 25 | fetchToken: mockFetchToken, 26 | ); 27 | }); 28 | 29 | tearDown(() { 30 | userLoginBloc?.close(); 31 | }); 32 | 33 | final String tEmail = 'test@test.com'; 34 | final String tPassword = 'test'; 35 | 36 | test('should initial state equals to NotLoggedIn', () async { 37 | //assert 38 | expect(userLoginBloc.initialState, equals(NotLoggedState())); 39 | }); 40 | 41 | group( 42 | 'loginUser', 43 | () { 44 | test('should return an error if login is not successfull', () async { 45 | //arrange 46 | when(mockLoginUser(any)).thenAnswer((_) async => Left(ServerFailure())); 47 | 48 | //act 49 | userLoginBloc.add(LoginEvent(tEmail, tPassword)); 50 | 51 | //assert 52 | expectLater( 53 | userLoginBloc, 54 | emitsInOrder( 55 | [ 56 | NotLoggedState(), 57 | LoadingState(), 58 | ErrorState(message: LOGGING_ERROR) 59 | ], 60 | ), 61 | ); 62 | }); 63 | 64 | test( 65 | 'should return LoggedState if login is successfull', 66 | () async { 67 | //arrange 68 | when(mockLoginUser(any)) 69 | .thenAnswer((_) async => Right(Login(token: "1234"))); 70 | 71 | //act 72 | userLoginBloc.add(LoginEvent(tEmail, tPassword)); 73 | 74 | //assert 75 | expect( 76 | userLoginBloc, 77 | emitsInOrder( 78 | [ 79 | NotLoggedState(), 80 | LoadingState(), 81 | LoggedState(login: Login(token: "1234")) 82 | ], 83 | ), 84 | ); 85 | }, 86 | ); 87 | }, 88 | ); 89 | 90 | group('fetchToken', (){ 91 | test('should return the token if exists', () async { 92 | //arrange 93 | when(mockFetchToken(any)).thenAnswer((_) async => Right(Login(token: "1234"))); 94 | 95 | //act 96 | userLoginBloc.add(CheckLoginStatusEvent()); 97 | 98 | //assert 99 | expect( 100 | userLoginBloc, 101 | emitsInOrder( 102 | [ 103 | NotLoggedState(), 104 | LoadingState(), 105 | LoggedState(login: Login(token: "1234")), 106 | ], 107 | ), 108 | ); 109 | }); 110 | }); 111 | } 112 | -------------------------------------------------------------------------------- /test_driver/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_driver/driver_extension.dart'; 2 | import 'package:clean_architecture_with_bloc_app/main.dart' as app; 3 | 4 | void main() { 5 | // This line enables the extension. 6 | enableFlutterDriverExtension(); 7 | 8 | // Call the `main()` function of the app, or call `runApp` with 9 | // any widget you are interested in testing. 10 | app.main(); 11 | } -------------------------------------------------------------------------------- /test_driver/app_test.dart: -------------------------------------------------------------------------------- 1 | // Imports the Flutter Driver API. 2 | import 'package:flutter_driver/flutter_driver.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | group('Demp App', () { 7 | final skipLoginButtonFinder = find.byValueKey('skipLogin'); 8 | 9 | FlutterDriver driver; 10 | 11 | // Connect to the Flutter driver before running any tests. 12 | setUpAll(() async { 13 | driver = await FlutterDriver.connect(); 14 | }); 15 | 16 | // Close the connection to the driver after the tests have completed. 17 | tearDownAll(() async { 18 | if (driver != null) { 19 | driver.close(); 20 | } 21 | }); 22 | 23 | test('tap on skip login button', () async { 24 | // First, tap the button. 25 | await driver.tap(skipLoginButtonFinder); 26 | 27 | //Check if the navigation is done correctly 28 | await driver.waitFor(find.text("Draft Home")); 29 | }); 30 | 31 | test('tap on change password button', () async { 32 | // First, tap the button. 33 | final changePasswordButtonFinder = find.byValueKey('changePassword'); 34 | await driver.tap(changePasswordButtonFinder); 35 | 36 | //Check if the navigation is done correctly 37 | await driver.waitFor(find.text("Change Password")); 38 | }); 39 | 40 | test('tap on change password button', () async { 41 | // First, tap the button. 42 | final changePasswordButtonFinder = find.byValueKey('changePassword'); 43 | await driver.tap(changePasswordButtonFinder); 44 | 45 | //Check if the navigation is done correctly 46 | await driver.waitFor(find.byValueKey("snackbar")); 47 | }); 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /upload_artifacts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ "$CIRRUS_RELEASE" == "" ]]; then 4 | echo "Not a release. No need to deploy!" 5 | exit 0 6 | fi 7 | 8 | if [[ "$GITHUB_TOKEN" == "" ]]; then 9 | echo "Please provide GitHub access token via GITHUB_TOKEN environment variable!" 10 | exit 1 11 | fi 12 | 13 | file_content_type="application/octet-stream" 14 | files_to_upload=( 15 | "build/app/outputs/apk/release/app-armeabi-v7a-release.apk" 16 | "build/app/outputs/apk/release/app-arm64-v8a-release.apk" 17 | "build/app/outputs/bundle/release/app-release.aab" 18 | ) 19 | 20 | for fpath in "${files_to_upload[@]}" 21 | do 22 | echo "Uploading $fpath..." 23 | name=$(basename "$fpath") 24 | url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=$name" 25 | curl -X POST \ 26 | --data-binary @$fpath \ 27 | --header "Authorization: token $GITHUB_TOKEN" \ 28 | --header "Content-Type: $file_content_type" \ 29 | $url_to_upload 30 | done --------------------------------------------------------------------------------