├── Flutter_Clean_Architecture.png ├── LICENSE ├── README.md ├── hacker_news ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── blackjade │ │ │ │ └── hackernews │ │ │ │ └── MainActivity.kt │ │ │ └── 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 │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── 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 │ ├── cache │ │ ├── ArticleCacheImpl.dart │ │ ├── PreferencesHelper.dart │ │ ├── db │ │ │ ├── ArticleDbMapper.dart │ │ │ ├── Db.dart │ │ │ └── DbHelper.dart │ │ ├── mapper │ │ │ ├── ArticleCacheMapper.dart │ │ │ └── Mapper.dart │ │ └── model │ │ │ └── CachedArticle.dart │ ├── data │ │ ├── ArticleDataRepository.dart │ │ ├── mapper │ │ │ ├── ArticleDataMapper.dart │ │ │ └── Mapper.dart │ │ ├── model │ │ │ └── ArticleEntity.dart │ │ ├── repository │ │ │ ├── ArticleCache.dart │ │ │ └── ArticleRemote.dart │ │ └── source │ │ │ ├── ArticleCacheDataStore.dart │ │ │ ├── ArticleDataStore.dart │ │ │ ├── ArticleDataStoreFactory.dart │ │ │ └── ArticleRemoteDataStore.dart │ ├── domain │ │ ├── ArticleRepository.dart │ │ ├── interactor │ │ │ ├── FutureUseCase.dart │ │ │ └── news │ │ │ │ └── GetArticles.dart │ │ └── model │ │ │ └── Article.dart │ ├── main.dart │ ├── presentation │ │ ├── BasePresenter.dart │ │ ├── BaseView.dart │ │ ├── mapper │ │ │ ├── ArticleViewMapper.dart │ │ │ └── Mapper.dart │ │ ├── model │ │ │ └── ArticleView.dart │ │ └── news │ │ │ ├── ArticleListContract.dart │ │ │ └── ArticleListPresenter.dart │ ├── remote │ │ ├── ArticleRemoteImpl.dart │ │ ├── mapper │ │ │ ├── ArticleRemoteMapper.dart │ │ │ └── Mapper.dart │ │ └── model │ │ │ └── RemoteArticle.dart │ └── ui │ │ ├── HackerNewsApplication.dart │ │ ├── injection │ │ ├── ApplicationModule.dart │ │ ├── ArticleListModule.dart │ │ ├── Injector.dart │ │ └── Module.dart │ │ ├── mapper │ │ ├── ArticleViewModelMapper.dart │ │ └── Mapper.dart │ │ ├── model │ │ └── ArticleViewModel.dart │ │ └── news │ │ ├── ArticleListPage.dart │ │ └── ArticleListView.dart ├── pubspec.yaml └── test │ └── widget_test.dart └── sample.png /Flutter_Clean_Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/Flutter_Clean_Architecture.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Lost In Ireland 2 | 3 | Anti 996 License Version 1.0 (Draft) 4 | 5 | Permission is hereby granted to any individual or legal entity 6 | obtaining a copy of this licensed work (including the source code, 7 | documentation and/or related items, hereinafter collectively referred 8 | to as the "licensed work"), free of charge, to deal with the licensed 9 | work for any purpose, including without limitation, the rights to use, 10 | reproduce, modify, prepare derivative works of, distribute, publish 11 | and sublicense the licensed work, subject to the following conditions: 12 | 13 | 1. The individual or the legal entity must conspicuously display, 14 | without modification, this License and the notice on each redistributed 15 | or derivative copy of the Licensed Work. 16 | 17 | 2. The individual or the legal entity must strictly comply with all 18 | applicable laws, regulations, rules and standards of the jurisdiction 19 | relating to labor and employment where the individual is physically 20 | located or where the individual was born or naturalized; or where the 21 | legal entity is registered or is operating (whichever is stricter). In 22 | case that the jurisdiction has no such laws, regulations, rules and 23 | standards or its laws, regulations, rules and standards are 24 | unenforceable, the individual or the legal entity are required to 25 | comply with Core International Labor Standards. 26 | 27 | 3. The individual or the legal entity shall not induce or force its 28 | employee(s), whether full-time or part-time, or its independent 29 | contractor(s), in any methods, to agree in oral or written form, to 30 | directly or indirectly restrict, weaken or relinquish his or her 31 | rights or remedies under such laws, regulations, rules and standards 32 | relating to labor and employment as mentioned above, no matter whether 33 | such written or oral agreement are enforceable under the laws of the 34 | said jurisdiction, nor shall such individual or the legal entity 35 | limit, in any methods, the rights of its employee(s) or independent 36 | contractor(s) from reporting or complaining to the copyright holder or 37 | relevant authorities monitoring the compliance of the license about 38 | its violation(s) of the said license. 39 | 40 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 41 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 42 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 43 | IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, 44 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 45 | OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE 46 | LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Clean Architecture Example 2 | An flutter teamplate project using clean architecture 3 | 4 | Welcome, I hope this example is not only helpful to other developers, but also that it helps to educate in the area of architecture. I created this example for a few reasons: 5 | 1. To experiment with modularization 6 | 2. To share some approaches to clean architecture, especially as we've been talking a lot about it 7 | 3. To use as a starting point in future projects where clean architecture feels appropriate 8 | It is written 100% in Flutter/Dart with both UI and Unit tests – I’d like to keep this up-to-date as libraries change! 9 | 10 | **Disclaimer** 11 | 12 | Clean Architecture is not be appropriate for every project, so it is down to you to decide whether or not it fits your needs 13 | 14 | ## Dependencies 15 | ``` 16 | http: 0.12.0 17 | shared_preferences: ^0.4.3 18 | sqflite: ^1.0.0 19 | path_provider: ^0.4.1 20 | kiwi: ^0.1.0 21 | ``` 22 | 23 | ## Architecture 24 | The architecture of the project follows the principles of Clean Architecture. Here's how the sample project implements it: 25 | ![Screenshot](Flutter_Clean_Architecture.png?raw=true) 26 | 27 | The sample app when run will show you a simple list of hacker news (Same as the Flutter boring show https://www.youtube.com/watch?v=CPmN4-i9zC8&list=PLOU2XLYxmsIK0r_D-zWcmJ1plIcDNnRkK). 28 | 29 | ![Screenshot](sample.png) 30 | 31 | 32 | 33 | 34 | 35 | ## Thanks 36 | A special thanks to the authors involved with these two repositories, they were a great resource during my learning! 37 | * https://github.com/android10/Android-CleanArchitecture 38 | * https://github.com/bufferapp/android-clean-architecture-boilerplate 39 | -------------------------------------------------------------------------------- /hacker_news/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.lock 4 | *.log 5 | *.pyc 6 | *.swp 7 | .DS_Store 8 | .atom/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # Visual Studio Code related 20 | .vscode/ 21 | 22 | # Flutter/Dart/Pub related 23 | **/doc/api/ 24 | .dart_tool/ 25 | .flutter-plugins 26 | .packages 27 | .pub-cache/ 28 | .pub/ 29 | build/ 30 | 31 | # Android related 32 | **/android/**/gradle-wrapper.jar 33 | **/android/.gradle 34 | **/android/captures/ 35 | **/android/gradlew 36 | **/android/gradlew.bat 37 | **/android/local.properties 38 | **/android/**/GeneratedPluginRegistrant.java 39 | 40 | # iOS/XCode related 41 | **/ios/**/*.mode1v3 42 | **/ios/**/*.mode2v3 43 | **/ios/**/*.moved-aside 44 | **/ios/**/*.pbxuser 45 | **/ios/**/*.perspectivev3 46 | **/ios/**/*sync/ 47 | **/ios/**/.sconsign.dblite 48 | **/ios/**/.tags* 49 | **/ios/**/.vagrant/ 50 | **/ios/**/DerivedData/ 51 | **/ios/**/Icon? 52 | **/ios/**/Pods/ 53 | **/ios/**/.symlinks/ 54 | **/ios/**/profile 55 | **/ios/**/xcuserdata 56 | **/ios/.generated/ 57 | **/ios/Flutter/App.framework 58 | **/ios/Flutter/Flutter.framework 59 | **/ios/Flutter/Generated.xcconfig 60 | **/ios/Flutter/app.flx 61 | **/ios/Flutter/app.zip 62 | **/ios/Flutter/flutter_assets/ 63 | **/ios/ServiceDefinitions.json 64 | **/ios/Runner/GeneratedPluginRegistrant.* 65 | 66 | # Exceptions to above rules. 67 | !**/ios/**/default.mode1v3 68 | !**/ios/**/default.mode2v3 69 | !**/ios/**/default.pbxuser 70 | !**/ios/**/default.perspectivev3 71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 72 | -------------------------------------------------------------------------------- /hacker_news/.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: 5391447fae6209bb21a89e6a5a6583cac1af9b4b 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /hacker_news/README.md: -------------------------------------------------------------------------------- 1 | # hacker_news 2 | 3 | A Flutter Application in Clean Architecture 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.io/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /hacker_news/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 27 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.blackjade.hackernews" 42 | minSdkVersion 16 43 | targetSdkVersion 27 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | } 68 | -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 15 | 19 | 26 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/kotlin/com/blackjade/hackernews/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.blackjade.hackernews 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | GeneratedPluginRegistrant.registerWith(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /hacker_news/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /hacker_news/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /hacker_news/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /hacker_news/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-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /hacker_news/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 | -------------------------------------------------------------------------------- /hacker_news/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /hacker_news/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /hacker_news/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /hacker_news/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 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 16 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 17 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 19 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 20 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 21 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXCopyFilesBuildPhase section */ 25 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 26 | isa = PBXCopyFilesBuildPhase; 27 | buildActionMask = 2147483647; 28 | dstPath = ""; 29 | dstSubfolderSpec = 10; 30 | files = ( 31 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 32 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 33 | ); 34 | name = "Embed Frameworks"; 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXCopyFilesBuildPhase section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 41 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 42 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 43 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 44 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 45 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 46 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 47 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 48 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 49 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 50 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 51 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 64 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 65 | ); 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | /* End PBXFrameworksBuildPhase section */ 69 | 70 | /* Begin PBXGroup section */ 71 | 9740EEB11CF90186004384FC /* Flutter */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 75 | 3B80C3931E831B6300D905FE /* App.framework */, 76 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 77 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 78 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 79 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 80 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 81 | ); 82 | name = Flutter; 83 | sourceTree = ""; 84 | }; 85 | 97C146E51CF9000F007C117D = { 86 | isa = PBXGroup; 87 | children = ( 88 | 9740EEB11CF90186004384FC /* Flutter */, 89 | 97C146F01CF9000F007C117D /* Runner */, 90 | 97C146EF1CF9000F007C117D /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 97C146EF1CF9000F007C117D /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 97C146EE1CF9000F007C117D /* Runner.app */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 97C146F01CF9000F007C117D /* Runner */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 106 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 107 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 108 | 97C147021CF9000F007C117D /* Info.plist */, 109 | 97C146F11CF9000F007C117D /* Supporting Files */, 110 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 111 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 112 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 113 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 114 | ); 115 | path = Runner; 116 | sourceTree = ""; 117 | }; 118 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | ); 122 | name = "Supporting Files"; 123 | sourceTree = ""; 124 | }; 125 | /* End PBXGroup section */ 126 | 127 | /* Begin PBXNativeTarget section */ 128 | 97C146ED1CF9000F007C117D /* Runner */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 131 | buildPhases = ( 132 | 9740EEB61CF901F6004384FC /* Run Script */, 133 | 97C146EA1CF9000F007C117D /* Sources */, 134 | 97C146EB1CF9000F007C117D /* Frameworks */, 135 | 97C146EC1CF9000F007C117D /* Resources */, 136 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 137 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = Runner; 144 | productName = Runner; 145 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | /* End PBXNativeTarget section */ 149 | 150 | /* Begin PBXProject section */ 151 | 97C146E61CF9000F007C117D /* Project object */ = { 152 | isa = PBXProject; 153 | attributes = { 154 | LastUpgradeCheck = 0910; 155 | ORGANIZATIONNAME = "The Chromium Authors"; 156 | TargetAttributes = { 157 | 97C146ED1CF9000F007C117D = { 158 | CreatedOnToolsVersion = 7.3.1; 159 | LastSwiftMigration = 0910; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | Base, 170 | ); 171 | mainGroup = 97C146E51CF9000F007C117D; 172 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | 97C146ED1CF9000F007C117D /* Runner */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 97C146EC1CF9000F007C117D /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 187 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 188 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 189 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 190 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 191 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXShellScriptBuildPhase section */ 198 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 199 | isa = PBXShellScriptBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | ); 203 | inputPaths = ( 204 | ); 205 | name = "Thin Binary"; 206 | outputPaths = ( 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | shellPath = /bin/sh; 210 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 211 | }; 212 | 9740EEB61CF901F6004384FC /* Run Script */ = { 213 | isa = PBXShellScriptBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | ); 217 | inputPaths = ( 218 | ); 219 | name = "Run Script"; 220 | outputPaths = ( 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | shellPath = /bin/sh; 224 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 225 | }; 226 | /* End PBXShellScriptBuildPhase section */ 227 | 228 | /* Begin PBXSourcesBuildPhase section */ 229 | 97C146EA1CF9000F007C117D /* Sources */ = { 230 | isa = PBXSourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 234 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | /* End PBXSourcesBuildPhase section */ 239 | 240 | /* Begin PBXVariantGroup section */ 241 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 242 | isa = PBXVariantGroup; 243 | children = ( 244 | 97C146FB1CF9000F007C117D /* Base */, 245 | ); 246 | name = Main.storyboard; 247 | sourceTree = ""; 248 | }; 249 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 250 | isa = PBXVariantGroup; 251 | children = ( 252 | 97C147001CF9000F007C117D /* Base */, 253 | ); 254 | name = LaunchScreen.storyboard; 255 | sourceTree = ""; 256 | }; 257 | /* End PBXVariantGroup section */ 258 | 259 | /* Begin XCBuildConfiguration section */ 260 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 261 | isa = XCBuildConfiguration; 262 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 263 | buildSettings = { 264 | ALWAYS_SEARCH_USER_PATHS = NO; 265 | CLANG_ANALYZER_NONNULL = YES; 266 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 267 | CLANG_CXX_LIBRARY = "libc++"; 268 | CLANG_ENABLE_MODULES = YES; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_COMMA = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INFINITE_RECURSION = YES; 278 | CLANG_WARN_INT_CONVERSION = YES; 279 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 280 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 282 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 283 | CLANG_WARN_STRICT_PROTOTYPES = YES; 284 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 285 | CLANG_WARN_UNREACHABLE_CODE = YES; 286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 288 | COPY_PHASE_STRIP = NO; 289 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 290 | ENABLE_NS_ASSERTIONS = NO; 291 | ENABLE_STRICT_OBJC_MSGSEND = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 295 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 296 | GCC_WARN_UNDECLARED_SELECTOR = YES; 297 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 298 | GCC_WARN_UNUSED_FUNCTION = YES; 299 | GCC_WARN_UNUSED_VARIABLE = YES; 300 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 301 | MTL_ENABLE_DEBUG_INFO = NO; 302 | SDKROOT = iphoneos; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | VALIDATE_PRODUCT = YES; 305 | }; 306 | name = Profile; 307 | }; 308 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 309 | isa = XCBuildConfiguration; 310 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 314 | DEVELOPMENT_TEAM = S8QB4VV633; 315 | ENABLE_BITCODE = NO; 316 | FRAMEWORK_SEARCH_PATHS = ( 317 | "$(inherited)", 318 | "$(PROJECT_DIR)/Flutter", 319 | ); 320 | INFOPLIST_FILE = Runner/Info.plist; 321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 322 | LIBRARY_SEARCH_PATHS = ( 323 | "$(inherited)", 324 | "$(PROJECT_DIR)/Flutter", 325 | ); 326 | PRODUCT_BUNDLE_IDENTIFIER = com.blackjade.hackerNews; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | SWIFT_VERSION = 4.0; 329 | VERSIONING_SYSTEM = "apple-generic"; 330 | }; 331 | name = Profile; 332 | }; 333 | 97C147031CF9000F007C117D /* Debug */ = { 334 | isa = XCBuildConfiguration; 335 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 336 | buildSettings = { 337 | ALWAYS_SEARCH_USER_PATHS = NO; 338 | CLANG_ANALYZER_NONNULL = YES; 339 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 340 | CLANG_CXX_LIBRARY = "libc++"; 341 | CLANG_ENABLE_MODULES = YES; 342 | CLANG_ENABLE_OBJC_ARC = YES; 343 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 344 | CLANG_WARN_BOOL_CONVERSION = YES; 345 | CLANG_WARN_COMMA = YES; 346 | CLANG_WARN_CONSTANT_CONVERSION = YES; 347 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 348 | CLANG_WARN_EMPTY_BODY = YES; 349 | CLANG_WARN_ENUM_CONVERSION = YES; 350 | CLANG_WARN_INFINITE_RECURSION = YES; 351 | CLANG_WARN_INT_CONVERSION = YES; 352 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = 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_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 407 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 409 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 410 | CLANG_WARN_STRICT_PROTOTYPES = YES; 411 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 412 | CLANG_WARN_UNREACHABLE_CODE = YES; 413 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 414 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 415 | COPY_PHASE_STRIP = NO; 416 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 417 | ENABLE_NS_ASSERTIONS = NO; 418 | ENABLE_STRICT_OBJC_MSGSEND = YES; 419 | GCC_C_LANGUAGE_STANDARD = gnu99; 420 | GCC_NO_COMMON_BLOCKS = YES; 421 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 422 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 423 | GCC_WARN_UNDECLARED_SELECTOR = YES; 424 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 425 | GCC_WARN_UNUSED_FUNCTION = YES; 426 | GCC_WARN_UNUSED_VARIABLE = YES; 427 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 428 | MTL_ENABLE_DEBUG_INFO = NO; 429 | SDKROOT = iphoneos; 430 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 431 | TARGETED_DEVICE_FAMILY = "1,2"; 432 | VALIDATE_PRODUCT = YES; 433 | }; 434 | name = Release; 435 | }; 436 | 97C147061CF9000F007C117D /* Debug */ = { 437 | isa = XCBuildConfiguration; 438 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 439 | buildSettings = { 440 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 441 | CLANG_ENABLE_MODULES = YES; 442 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 443 | ENABLE_BITCODE = NO; 444 | FRAMEWORK_SEARCH_PATHS = ( 445 | "$(inherited)", 446 | "$(PROJECT_DIR)/Flutter", 447 | ); 448 | INFOPLIST_FILE = Runner/Info.plist; 449 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 450 | LIBRARY_SEARCH_PATHS = ( 451 | "$(inherited)", 452 | "$(PROJECT_DIR)/Flutter", 453 | ); 454 | PRODUCT_BUNDLE_IDENTIFIER = com.blackjade.hackerNews; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 457 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 458 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 459 | SWIFT_VERSION = 4.0; 460 | VERSIONING_SYSTEM = "apple-generic"; 461 | }; 462 | name = Debug; 463 | }; 464 | 97C147071CF9000F007C117D /* Release */ = { 465 | isa = XCBuildConfiguration; 466 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | CLANG_ENABLE_MODULES = YES; 470 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 471 | ENABLE_BITCODE = NO; 472 | FRAMEWORK_SEARCH_PATHS = ( 473 | "$(inherited)", 474 | "$(PROJECT_DIR)/Flutter", 475 | ); 476 | INFOPLIST_FILE = Runner/Info.plist; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 478 | LIBRARY_SEARCH_PATHS = ( 479 | "$(inherited)", 480 | "$(PROJECT_DIR)/Flutter", 481 | ); 482 | PRODUCT_BUNDLE_IDENTIFIER = com.blackjade.hackerNews; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 485 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 486 | SWIFT_VERSION = 4.0; 487 | VERSIONING_SYSTEM = "apple-generic"; 488 | }; 489 | name = Release; 490 | }; 491 | /* End XCBuildConfiguration section */ 492 | 493 | /* Begin XCConfigurationList section */ 494 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 495 | isa = XCConfigurationList; 496 | buildConfigurations = ( 497 | 97C147031CF9000F007C117D /* Debug */, 498 | 97C147041CF9000F007C117D /* Release */, 499 | 249021D3217E4FDB00AE95B9 /* Profile */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 97C147061CF9000F007C117D /* Debug */, 508 | 97C147071CF9000F007C117D /* Release */, 509 | 249021D4217E4FDB00AE95B9 /* Profile */, 510 | ); 511 | defaultConfigurationIsVisible = 0; 512 | defaultConfigurationName = Release; 513 | }; 514 | /* End XCConfigurationList section */ 515 | 516 | }; 517 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 518 | } 519 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /hacker_news/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: [UIApplicationLaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hacker_news/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 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /hacker_news/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 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/hacker_news/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /hacker_news/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. -------------------------------------------------------------------------------- /hacker_news/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 | -------------------------------------------------------------------------------- /hacker_news/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 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | hacker_news 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 | -------------------------------------------------------------------------------- /hacker_news/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /hacker_news/lib/cache/ArticleCacheImpl.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/cache/PreferencesHelper.dart'; 2 | import 'package:hacker_news/cache/db/ArticleDbMapper.dart'; 3 | import 'package:hacker_news/cache/db/Db.dart'; 4 | import 'package:hacker_news/cache/db/DbHelper.dart'; 5 | import 'package:hacker_news/cache/mapper/ArticleCacheMapper.dart'; 6 | import 'package:hacker_news/cache/model/CachedArticle.dart'; 7 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 8 | import 'package:hacker_news/data/repository/ArticleCache.dart'; 9 | 10 | /// Cached implementation for retrieving and saving Article instances. 11 | /// This class implements the [ArticleCache] from the Data layer as 12 | /// it is that layers responsibility for defining the operations in 13 | /// which data store implementation layers can carry out. 14 | class ArticleCacheImpl implements ArticleCache { 15 | static const int EXPIRATION_TIME = (1000 * 60); 16 | 17 | ArticleDbMapper articleDbMapper; 18 | ArticleCacheMapper articleCacheMapper; 19 | DbHelper dbHelper; 20 | PreferencesHelper preferencesHelper; 21 | 22 | ArticleCacheImpl(this.dbHelper, this.preferencesHelper, 23 | this.articleCacheMapper, this.articleDbMapper); 24 | 25 | /// Remove all the data from all the tables in the database. 26 | @override 27 | Future clearArticles() async { 28 | var database = await dbHelper.database; 29 | return database.delete(ArticleTable.TABLE_NAME); 30 | } 31 | 32 | /// Save the given list of [ArticleEntity] instances to the database. 33 | @override 34 | Future saveArticles(List articles) async { 35 | articles.forEach((it) => saveArticle(articleCacheMapper.mapToCache(it))); 36 | } 37 | 38 | /// Helper method for saving a [CachedArticle] instance to the database. 39 | Future saveArticle(CachedArticle article) async { 40 | var database = await dbHelper.database; 41 | return await database.insert( 42 | ArticleTable.TABLE_NAME, articleDbMapper.mapToMapValues(article)); 43 | } 44 | 45 | /// Retrieve a list of [ArticleEntity] instances from the database. 46 | @override 47 | Future> getArticles() async { 48 | var database = await dbHelper.database; 49 | List> mapValuesList = 50 | await database.query(ArticleTable.TABLE_NAME); 51 | 52 | List articles = mapValuesList.isNotEmpty 53 | ? mapValuesList 54 | .map((it) => articleCacheMapper 55 | .mapFromCache(articleDbMapper.mapFromMapValues(it))) 56 | .toList() 57 | : []; 58 | 59 | return articles; 60 | } 61 | 62 | /// Checked whether there are instances of [CachedArticle] stored in the cache 63 | @override 64 | Future isCached() async { 65 | var database = await dbHelper.database; 66 | List> mapValuesList = 67 | await database.query(ArticleTable.TABLE_NAME); 68 | return mapValuesList.length > 0; 69 | } 70 | 71 | /// Set a point in time at when the cache was last updated 72 | @override 73 | Future setLastCacheTime(int lastCacheTime) async { 74 | await preferencesHelper.setLastCacheTime(lastCacheTime); 75 | } 76 | 77 | /// Check whether the current cached data exceeds the defined [EXPIRATION_TIME] time 78 | @override 79 | Future isExpired() async { 80 | int currentTimeMills = new DateTime.now().millisecondsSinceEpoch; 81 | int lastUpdateTime = await preferencesHelper.getLastCacheTime(); 82 | return currentTimeMills - lastUpdateTime > EXPIRATION_TIME; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /hacker_news/lib/cache/PreferencesHelper.dart: -------------------------------------------------------------------------------- 1 | import 'package:shared_preferences/shared_preferences.dart'; 2 | 3 | /// General Preferences Helper class, used for storing preference values using the Preference API 4 | class PreferencesHelper { 5 | static const String PREF_KEY_LAST_CACHE = "last_cache"; 6 | 7 | Future _prefs = SharedPreferences.getInstance(); 8 | 9 | Future setLastCacheTime(int cacheTime) async { 10 | final SharedPreferences sharedPreferences = await _prefs; 11 | sharedPreferences.setInt(PREF_KEY_LAST_CACHE, cacheTime); 12 | } 13 | 14 | Future getLastCacheTime() async { 15 | final SharedPreferences sharedPreferences = await _prefs; 16 | int cacheTime = sharedPreferences.getInt(PREF_KEY_LAST_CACHE) ?? 0; 17 | return cacheTime; 18 | } 19 | } -------------------------------------------------------------------------------- /hacker_news/lib/cache/db/ArticleDbMapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/cache/db/Db.dart'; 2 | import 'package:hacker_news/cache/model/CachedArticle.dart'; 3 | 4 | /// Maps a [CachedArticle] instance to and from a database entity [Map]. 5 | class ArticleDbMapper { 6 | 7 | /// Construct an instance of [Map] using the given [CachedArticle] 8 | Map mapToMapValues(CachedArticle model) { 9 | return { 10 | ArticleTable.ID: model.id, 11 | ArticleTable.TITLE: model.title, 12 | ArticleTable.TYPE: model.type, 13 | ArticleTable.DESCENDANTS: model.descendants 14 | }; 15 | } 16 | 17 | /// Parse the [Map] instance to a [CachedArticle] instance. 18 | CachedArticle mapFromMapValues(Map values) { 19 | return CachedArticle( 20 | values[ArticleTable.ID], 21 | values[ArticleTable.TITLE], 22 | values[ArticleTable.TYPE], 23 | values[ArticleTable.DESCENDANTS] 24 | ); 25 | } 26 | } -------------------------------------------------------------------------------- /hacker_news/lib/cache/db/Db.dart: -------------------------------------------------------------------------------- 1 | /// This class defines the tables found within the application Database. 2 | /// All table definitions should contain column names and a sequence for creating the table. 3 | class ArticleTable { 4 | static const String TABLE_NAME = "tbl_article"; 5 | 6 | static const String ID = "id"; 7 | static const String TITLE = "title"; 8 | static const String TYPE = "type"; 9 | static const String DESCENDANTS = "descendants"; 10 | 11 | static const String CREATE = "CREATE TABLE " + 12 | TABLE_NAME + 13 | " (" + 14 | ID + 15 | " INTEGER PRIMARY KEY NOT NULL," + 16 | TITLE + 17 | " TEXT," + 18 | TYPE + 19 | " TEXT," + 20 | DESCENDANTS + 21 | " INTEGER" + 22 | "); "; 23 | } 24 | -------------------------------------------------------------------------------- /hacker_news/lib/cache/db/DbHelper.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:hacker_news/cache/db/Db.dart'; 4 | import 'package:path/path.dart'; 5 | import 'package:path_provider/path_provider.dart'; 6 | import 'package:sqflite/sqflite.dart'; 7 | 8 | /// Standard DB class for configuring the Database and handling migrations during upgrades 9 | class DbHelper { 10 | static const String DATABASE_NAME = "nownowwitch.db"; 11 | static const int DATABASE_VERSION = 1; 12 | 13 | static final DbHelper _instance = new DbHelper.internal(); 14 | factory DbHelper() => _instance; 15 | DbHelper.internal(); 16 | 17 | static Database _database; 18 | 19 | Future get database async { 20 | if (_database != null) { 21 | return _database; 22 | } 23 | _database = await initDB(); 24 | return _database; 25 | } 26 | 27 | Future initDB() async { 28 | Directory documentsDirectory = await getApplicationDocumentsDirectory(); 29 | String path = join(documentsDirectory.path, DATABASE_NAME); 30 | var db = await openDatabase(path, version: DATABASE_VERSION, 31 | onOpen: (db) {}, 32 | onCreate: onCreate, 33 | onUpgrade: onUpgrade); 34 | return db; 35 | } 36 | 37 | Future onCreate(Database db, int version) async{ 38 | return await db.execute(ArticleTable.CREATE); 39 | } 40 | 41 | void onUpgrade(Database db, int oldVersion, int newVersion){ 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /hacker_news/lib/cache/mapper/ArticleCacheMapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/cache/mapper/Mapper.dart'; 2 | import 'package:hacker_news/cache/model/CachedArticle.dart'; 3 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 4 | 5 | /// Map a [CachedArticle] instance to and from a [ArticleEntity] instance 6 | /// when data is moving between the cache later and the Data layer 7 | class ArticleCacheMapper implements Mapper { 8 | @override 9 | ArticleEntity mapFromCache(CachedArticle type) { 10 | return ArticleEntity(type.id, type.title, type.type, type.descendants); 11 | } 12 | 13 | @override 14 | CachedArticle mapToCache(ArticleEntity type) { 15 | return CachedArticle(type.id, type.title, type.type, type.descendants); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /hacker_news/lib/cache/mapper/Mapper.dart: -------------------------------------------------------------------------------- 1 | abstract class Mapper { 2 | E mapFromCache(C type); 3 | 4 | C mapToCache(E type); 5 | } -------------------------------------------------------------------------------- /hacker_news/lib/cache/model/CachedArticle.dart: -------------------------------------------------------------------------------- 1 | /// Model used solely for the caching of an article 2 | class CachedArticle { 3 | int id; 4 | String title; 5 | String type; 6 | int descendants; 7 | 8 | CachedArticle(this.id, this.title, this.type, this.descendants); 9 | } 10 | -------------------------------------------------------------------------------- /hacker_news/lib/data/ArticleDataRepository.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/mapper/ArticleDataMapper.dart'; 2 | import 'package:hacker_news/data/source/ArticleDataStoreFactory.dart'; 3 | import 'package:hacker_news/data/source/ArticleRemoteDataStore.dart'; 4 | import 'package:hacker_news/domain/ArticleRepository.dart'; 5 | import 'package:hacker_news/domain/model/Article.dart'; 6 | 7 | /// Provides an implementation of the [ArticleRepository] interface for 8 | /// communicating to and from data sources 9 | class ArticleDataRepository implements ArticleRepository { 10 | ArticleDataStoreFactory factory; 11 | ArticleDataMapper mapper; 12 | 13 | ArticleDataRepository(this.factory, this.mapper); 14 | 15 | @override 16 | Future> getArticles() async { 17 | var dataStore = await factory.retrieveDataStore(); 18 | var articles = await dataStore.getArticles(); 19 | 20 | // Save Remote data to cache 21 | if (dataStore is ArticleRemoteDataStore) { 22 | clearArticles(); 23 | factory.retrieveCacheDataStore().saveArticles(articles); 24 | } 25 | return articles.map((it) => mapper.mapFromEntity(it)).toList(); 26 | } 27 | 28 | void clearArticles() { 29 | factory.retrieveCacheDataStore().clearArticles(); 30 | } 31 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/mapper/ArticleDataMapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/mapper/Mapper.dart'; 2 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 3 | import 'package:hacker_news/domain/model/Article.dart'; 4 | 5 | /// Map a [ArticleEntity] to and from a [Article] instance when data is 6 | /// moving between this later and the Domain layer 7 | class ArticleDataMapper implements Mapper { 8 | 9 | /// Map a [ArticleEntity] instance to a [Article] instance 10 | @override 11 | Article mapFromEntity(ArticleEntity type) { 12 | return Article(type.id, type.title, ArticleType(type.type), type.descendants); 13 | } 14 | 15 | /// Map a [Article] instance to a [ArticleEntity] instance 16 | @override 17 | ArticleEntity mapToEntity(Article type) { 18 | return ArticleEntity(type.id, type.title, type.type.value, type.descendants); 19 | } 20 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/mapper/Mapper.dart: -------------------------------------------------------------------------------- 1 | /// Interface for model mappers. It provides helper methods that facilitate 2 | /// retrieving of models from outer data source layers 3 | abstract class Mapper { 4 | D mapFromEntity(E type); 5 | 6 | E mapToEntity(D type); 7 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/model/ArticleEntity.dart: -------------------------------------------------------------------------------- 1 | 2 | /// Representation for a [ArticleEntity] fetched from an external layer data source 3 | class ArticleEntity { 4 | int id; 5 | String title; 6 | String type; 7 | int descendants; 8 | 9 | ArticleEntity(this.id, this.title, this.type, this.descendants); 10 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/repository/ArticleCache.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 2 | 3 | /// Interface defining methods for the caching of Articles. 4 | /// This is to be implemented by the cache layer, using this interface as a way of communicating. 5 | abstract class ArticleCache { 6 | 7 | /// Clear all Articles from the cache 8 | Future clearArticles(); 9 | 10 | /// Save a given list of Article to the cache 11 | Future saveArticles(List articles); 12 | 13 | /// Retrieve a list of Article, from the cache 14 | Future> getArticles(); 15 | 16 | /// Checks if an element (Article) exists in the cache. 17 | Future isCached(); 18 | 19 | /// Save the time of an element (Article) cached. 20 | Future setLastCacheTime(int lastCacheTime); 21 | 22 | /// Checks if the cache is expired. 23 | Future isExpired(); 24 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/repository/ArticleRemote.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 3 | 4 | /// Interface defining methods for the retrieve of Articles. 5 | /// This is to be implemented by the remote layer, using this interface as a way of communicating 6 | abstract class ArticleRemote { 7 | 8 | /// Retrieve a list of Articles, from the remote 9 | Future> getArticles(); 10 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/source/ArticleCacheDataStore.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 2 | import 'package:hacker_news/data/repository/ArticleCache.dart'; 3 | import 'package:hacker_news/data/source/ArticleDataStore.dart'; 4 | 5 | /// Implementation of the [ArticleDataStore] interface to 6 | /// provide a means of communicating with the local data source 7 | class ArticleCacheDataStore implements ArticleDataStore { 8 | ArticleCache articleCache; 9 | 10 | ArticleCacheDataStore(this.articleCache); 11 | 12 | /// Clear all Articles from the cache 13 | @override 14 | void clearArticles() { 15 | articleCache.clearArticles(); 16 | } 17 | 18 | /// Retrieve a list of [ArticleEntity] instance from the remote 19 | @override 20 | Future> getArticles() { 21 | return articleCache.getArticles(); 22 | } 23 | 24 | /// Save a given list of [ArticleEntity] instances to the cache 25 | @override 26 | void saveArticles(List articles) async { 27 | await articleCache.saveArticles(articles); 28 | await articleCache.setLastCacheTime(DateTime.now().millisecondsSinceEpoch); 29 | } 30 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/source/ArticleDataStore.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 2 | 3 | /// Interface defining methods for the data operations related to Articles. 4 | /// This is to be implemented by external data source layers, 5 | /// setting the requirements for the operations that need to be implemented 6 | abstract class ArticleDataStore { 7 | 8 | void clearArticles(); 9 | 10 | void saveArticles(List articles); 11 | 12 | Future> getArticles(); 13 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/source/ArticleDataStoreFactory.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/repository/ArticleCache.dart'; 2 | import 'package:hacker_news/data/source/ArticleCacheDataStore.dart'; 3 | import 'package:hacker_news/data/source/ArticleDataStore.dart'; 4 | import 'package:hacker_news/data/source/ArticleRemoteDataStore.dart'; 5 | 6 | /// Create an instance of a ArticleDataStore 7 | class ArticleDataStoreFactory { 8 | ArticleCache articleCache; 9 | ArticleCacheDataStore articleCacheDataStore; 10 | ArticleRemoteDataStore articleRemoteDataStore; 11 | 12 | ArticleDataStoreFactory(this.articleCache, this.articleCacheDataStore, 13 | this.articleRemoteDataStore); 14 | 15 | /// Returns a DataStore based on whether or not there is content in the cache 16 | /// and the cache has not expired 17 | Future retrieveDataStore() async { 18 | if (await articleCache.isCached() && 19 | !await articleCache.isExpired()) { 20 | return retrieveCacheDataStore(); 21 | } 22 | return articleRemoteDataStore; 23 | } 24 | 25 | /// Return an instance of the Cache Data Store 26 | ArticleDataStore retrieveCacheDataStore() { 27 | return articleCacheDataStore; 28 | } 29 | 30 | /// Return an instance of the Remote Data Store 31 | ArticleDataStore retrieveRemoteDataStore() { 32 | return articleRemoteDataStore; 33 | } 34 | } -------------------------------------------------------------------------------- /hacker_news/lib/data/source/ArticleRemoteDataStore.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 2 | import 'package:hacker_news/data/repository/ArticleRemote.dart'; 3 | import 'package:hacker_news/data/source/ArticleDataStore.dart'; 4 | 5 | /// Implementation of the [ArticleDataStore] interface to 6 | /// provide a means of communicating with the remote data source 7 | class ArticleRemoteDataStore implements ArticleDataStore { 8 | ArticleRemote articleRemote; 9 | 10 | ArticleRemoteDataStore(this.articleRemote); 11 | 12 | @override 13 | void clearArticles() { 14 | throw UnsupportedError; 15 | } 16 | 17 | /// Retrieve a list of [ArticleEntity] instances from remote 18 | @override 19 | Future> getArticles() { 20 | return articleRemote.getArticles(); 21 | } 22 | 23 | @override 24 | void saveArticles(List articles) { 25 | throw UnsupportedError; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /hacker_news/lib/domain/ArticleRepository.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/domain/model/Article.dart'; 2 | 3 | /// Interface defining methods for how the data layer can pass data to and from the Domain layer. 4 | /// This is to be implemented by the data layer, setting the requirements for the 5 | /// operations that need to be implemented 6 | abstract class ArticleRepository { 7 | 8 | Future> getArticles(); 9 | 10 | } -------------------------------------------------------------------------------- /hacker_news/lib/domain/interactor/FutureUseCase.dart: -------------------------------------------------------------------------------- 1 | /// 2 | /// Abstract class for a UseCase that returns an instance of a [Future]. 3 | abstract class FutureUseCase { 4 | Future execute(In params); 5 | } -------------------------------------------------------------------------------- /hacker_news/lib/domain/interactor/news/GetArticles.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:hacker_news/domain/ArticleRepository.dart'; 4 | import 'package:hacker_news/domain/interactor/FutureUseCase.dart'; 5 | import 'package:hacker_news/domain/model/Article.dart'; 6 | 7 | /// Use case used for retrieving a [List] of [Article] instances from the [ArticleRepository] 8 | class GetArticles extends FutureUseCase> { 9 | ArticleRepository articleRepository; 10 | 11 | GetArticles(this.articleRepository); 12 | 13 | @override 14 | Future> execute(void params) { 15 | var articles = articleRepository.getArticles(); 16 | return articles; 17 | } 18 | } -------------------------------------------------------------------------------- /hacker_news/lib/domain/model/Article.dart: -------------------------------------------------------------------------------- 1 | /// Representation for a [Article] fetched from an external layer data source 2 | class Article { 3 | int id; 4 | String title; 5 | ArticleType type; 6 | int descendants; 7 | 8 | Article(this.id, this.title, this.type, this.descendants); 9 | 10 | } 11 | 12 | abstract class Enum { 13 | final T value; 14 | const Enum(this.value); 15 | } 16 | 17 | /// This is the type of the article. 18 | /// 19 | /// It can be any of these: "job", "story", "comment", "poll", or "pollopt". 20 | class ArticleType extends Enum { 21 | const ArticleType(String value) : super(value); 22 | 23 | static const ArticleType JOB = const ArticleType("job"); 24 | static const ArticleType STORY = const ArticleType("story"); 25 | static const ArticleType COMMENT = const ArticleType("comment"); 26 | static const ArticleType POLL = const ArticleType("poll"); 27 | static const ArticleType POLLOPT = const ArticleType("pollopt"); 28 | } -------------------------------------------------------------------------------- /hacker_news/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hacker_news/ui/HackerNewsApplication.dart'; 3 | import 'package:hacker_news/ui/injection/ApplicationModule.dart'; 4 | import 'package:hacker_news/ui/injection/ArticleListModule.dart'; 5 | import 'package:hacker_news/ui/injection/Injector.dart'; 6 | 7 | void main() { 8 | // Setup Injection 9 | injector.inject([ 10 | ApplicationModule(), 11 | ArticleListModule() 12 | ]); 13 | 14 | runApp(HackerNewsApplication()); 15 | } 16 | -------------------------------------------------------------------------------- /hacker_news/lib/presentation/BasePresenter.dart: -------------------------------------------------------------------------------- 1 | /// Interface class to act as a base for any class that is to 2 | /// take the role of the IPresenter in the Model-BaseView-IPresenter pattern. 3 | abstract class BasePresenter { 4 | 5 | void start(); 6 | 7 | void stop(); 8 | } 9 | -------------------------------------------------------------------------------- /hacker_news/lib/presentation/BaseView.dart: -------------------------------------------------------------------------------- 1 | /// Interface class to act as a base for any class that is 2 | /// to take the role of the BaseView in the Model-BaseView-Presenter pattern. 3 | abstract class BaseView { 4 | void setPresenter(presenter); 5 | } -------------------------------------------------------------------------------- /hacker_news/lib/presentation/mapper/ArticleViewMapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/domain/model/Article.dart'; 2 | import 'package:hacker_news/presentation/mapper/Mapper.dart'; 3 | import 'package:hacker_news/presentation/model/ArticleView.dart'; 4 | 5 | /// Map a [ArticleView] from a [Article] instance 6 | /// when data is moving between this layer and the Domain layer 7 | class ArticleViewMapper implements Mapper { 8 | @override 9 | ArticleView mapToView(Article type) { 10 | return ArticleView(type.id, type.title, type.type.value, type.descendants); 11 | } 12 | } -------------------------------------------------------------------------------- /hacker_news/lib/presentation/mapper/Mapper.dart: -------------------------------------------------------------------------------- 1 | /// Interface for model mappers. It provides helper methods 2 | /// that facilitate retrieving of models from outer layers 3 | abstract class Mapper { 4 | V mapToView(D type); 5 | } -------------------------------------------------------------------------------- /hacker_news/lib/presentation/model/ArticleView.dart: -------------------------------------------------------------------------------- 1 | /// Representation for a [ArticleView] instance for this layers Model representation 2 | class ArticleView { 3 | int id; 4 | String title; 5 | String type; 6 | int descendants; 7 | 8 | ArticleView(this.id, this.title, this.type, this.descendants); 9 | } -------------------------------------------------------------------------------- /hacker_news/lib/presentation/news/ArticleListContract.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/presentation/BasePresenter.dart'; 2 | import 'package:hacker_news/presentation/BaseView.dart'; 3 | import 'package:hacker_news/presentation/model/ArticleView.dart'; 4 | 5 | /// Defines a contract of operations between the ArticleList Presenter and ArticleList View 6 | abstract class Presenter extends BasePresenter { 7 | 8 | void getArticles(); 9 | 10 | } 11 | 12 | /// Defines a contract of operations between the ArticleList Presenter and ArticleList View 13 | abstract class View extends BaseView { 14 | 15 | void showProgress(); 16 | void hideProgress(); 17 | 18 | void updateArticles(List articles); 19 | } 20 | -------------------------------------------------------------------------------- /hacker_news/lib/presentation/news/ArticleListPresenter.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/domain/interactor/FutureUseCase.dart'; 2 | import 'package:hacker_news/domain/model/Article.dart'; 3 | import 'package:hacker_news/presentation/mapper/ArticleViewMapper.dart'; 4 | import 'package:hacker_news/presentation/news/ArticleListContract.dart'; 5 | 6 | class ArticleListPresenter implements Presenter { 7 | View view; 8 | FutureUseCase> getArticlesUseCase; 9 | ArticleViewMapper mapper; 10 | 11 | ArticleListPresenter(this.view, this.getArticlesUseCase, this.mapper); 12 | 13 | @override 14 | void start() { 15 | getArticles(); 16 | } 17 | 18 | @override 19 | void stop() {} 20 | 21 | @override 22 | void getArticles() { 23 | view.showProgress(); 24 | 25 | Future> future = getArticlesUseCase.execute(null); 26 | future.then((articles) { 27 | view.hideProgress(); 28 | view.updateArticles( 29 | articles.map((it) => mapper.mapToView(it)).toList()); 30 | }).catchError((e) { 31 | print(e); 32 | view.hideProgress(); 33 | }); 34 | } 35 | } -------------------------------------------------------------------------------- /hacker_news/lib/remote/ArticleRemoteImpl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 4 | import 'package:hacker_news/data/repository/ArticleRemote.dart'; 5 | import 'package:hacker_news/remote/mapper/ArticleRemoteMapper.dart'; 6 | import 'package:hacker_news/remote/model/RemoteArticle.dart'; 7 | import 'package:http/http.dart' as http; 8 | 9 | /// Remote implementation for retrieving Articles instances. 10 | /// This class implements the [ArticleRemote] from the Data layer 11 | /// as it is that layers responsibility for defining the operations in which 12 | /// data store implementation layers can carry out. 13 | class ArticleRemoteImpl implements ArticleRemote { 14 | final baseUrl = 'https://hacker-news.firebaseio.com/v0/'; 15 | ArticleRemoteMapper mapper; 16 | 17 | ArticleRemoteImpl(this.mapper); 18 | 19 | @override 20 | Future> getArticles() async { 21 | var articleIds = await getTenNewArticlesIds(); 22 | var articles = articleIds.map((id) => getArticle(id)).toList(); 23 | return Future.wait(articles); 24 | } 25 | 26 | Future> getTenNewArticlesIds() async { 27 | final response = await http.get('${baseUrl}newstories.json'); 28 | if (response.statusCode == 200) { 29 | List responseJson = json.decode(response.body); 30 | return List.from(responseJson).take(10).toList(); 31 | } 32 | throw Exception("New stories couldn't be fetched"); 33 | } 34 | 35 | Future getArticle(int id) async { 36 | final response = await http.get('${baseUrl}item/$id.json'); 37 | if (response.statusCode == 200) { 38 | var responseJson = json.decode(response.body); 39 | return mapper.mapFromRemote(RemoteArticle.fromJson(responseJson)); 40 | } 41 | throw Exception("Article $id couldn't be fetched."); 42 | } 43 | } -------------------------------------------------------------------------------- /hacker_news/lib/remote/mapper/ArticleRemoteMapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/data/model/ArticleEntity.dart'; 2 | import 'package:hacker_news/remote/mapper/Mapper.dart'; 3 | import 'package:hacker_news/remote/model/RemoteArticle.dart'; 4 | 5 | /// Map a [RemoteArticle] to a [ArticleEntity] instance 6 | /// when data is moving from the remote later to the Data layer 7 | class ArticleRemoteMapper implements Mapper { 8 | @override 9 | ArticleEntity mapFromRemote(RemoteArticle type) { 10 | return ArticleEntity(type.id, type.title, type.type, type.descendants); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /hacker_news/lib/remote/mapper/Mapper.dart: -------------------------------------------------------------------------------- 1 | /// Interface for model mappers. It provides helper methods that facilitate 2 | /// retrieving of models from outer data source layers 3 | abstract class Mapper { 4 | E mapFromRemote(R type); 5 | } -------------------------------------------------------------------------------- /hacker_news/lib/remote/model/RemoteArticle.dart: -------------------------------------------------------------------------------- 1 | /// Representation for a [RemoteArticle] fetched from the API 2 | class RemoteArticle { 3 | int id; 4 | String title; 5 | String type; 6 | int descendants; 7 | 8 | RemoteArticle(this.id, this.title, this.type, this.descendants); 9 | 10 | factory RemoteArticle.fromJson(Map json) { 11 | return RemoteArticle( 12 | json['id'], 13 | json['title'], 14 | json['type'], 15 | json['descendants'] 16 | ); 17 | } 18 | } -------------------------------------------------------------------------------- /hacker_news/lib/ui/HackerNewsApplication.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hacker_news/ui/news/ArticleListPage.dart'; 3 | 4 | class HackerNewsApplication extends StatelessWidget { 5 | @override 6 | Widget build(BuildContext context) { 7 | return MaterialApp( 8 | title: 'Flutter Clean Architecture Demo', 9 | theme: ThemeData( 10 | primarySwatch: Colors.blue, 11 | ), 12 | home: ArticleListPage( 13 | title: 'Flutter Hacker News', 14 | ), 15 | ); 16 | } 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /hacker_news/lib/ui/injection/ApplicationModule.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/ui/injection/Module.dart'; 2 | import 'package:hacker_news/cache/ArticleCacheImpl.dart'; 3 | import 'package:hacker_news/cache/PreferencesHelper.dart'; 4 | import 'package:hacker_news/cache/db/ArticleDbMapper.dart'; 5 | import 'package:hacker_news/cache/db/DbHelper.dart'; 6 | import 'package:hacker_news/cache/mapper/ArticleCacheMapper.dart'; 7 | import 'package:hacker_news/data/ArticleDataRepository.dart'; 8 | import 'package:hacker_news/data/mapper/ArticleDataMapper.dart'; 9 | import 'package:hacker_news/data/source/ArticleCacheDataStore.dart'; 10 | import 'package:hacker_news/data/source/ArticleDataStoreFactory.dart'; 11 | import 'package:hacker_news/data/source/ArticleRemoteDataStore.dart'; 12 | import 'package:hacker_news/domain/interactor/news/GetArticles.dart'; 13 | import 'package:hacker_news/presentation/mapper/ArticleViewMapper.dart'; 14 | import 'package:hacker_news/remote/ArticleRemoteImpl.dart'; 15 | import 'package:hacker_news/remote/mapper/ArticleRemoteMapper.dart'; 16 | import 'package:kiwi/kiwi.dart'; 17 | 18 | class ApplicationModule extends Module { 19 | @override 20 | void registerOn(Container container) { 21 | container.registerSingleton((it) => PreferencesHelper()); 22 | container.registerSingleton((it) => DbHelper()); 23 | 24 | container.registerInstance(ArticleCacheMapper()); 25 | container.registerInstance(ArticleDbMapper()); 26 | container.registerInstance(ArticleCacheImpl( 27 | container.resolve(), 28 | container.resolve(), 29 | container.resolve(), 30 | container.resolve(), 31 | )); 32 | 33 | container.registerInstance( 34 | ArticleCacheDataStore(container.resolve())); 35 | 36 | container.registerInstance(ArticleRemoteMapper()); 37 | container.registerInstance( 38 | ArticleRemoteImpl(container.resolve())); 39 | container.registerInstance( 40 | ArticleRemoteDataStore(container.resolve())); 41 | 42 | container.registerInstance(ArticleDataStoreFactory( 43 | container.resolve(), 44 | container.resolve(), 45 | container.resolve())); 46 | 47 | container.registerInstance(ArticleDataMapper()); 48 | 49 | container.registerInstance(ArticleDataRepository( 50 | container.resolve(), 51 | container.resolve())); 52 | 53 | container.registerInstance( 54 | GetArticles(container.resolve())); 55 | 56 | container.registerInstance(ArticleViewMapper()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /hacker_news/lib/ui/injection/ArticleListModule.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/domain/interactor/news/GetArticles.dart'; 2 | import 'package:hacker_news/presentation/mapper/ArticleViewMapper.dart'; 3 | import 'package:hacker_news/presentation/news/ArticleListPresenter.dart'; 4 | import 'package:hacker_news/ui/injection/Module.dart'; 5 | import 'package:hacker_news/ui/mapper/ArticleViewModelMapper.dart'; 6 | import 'package:hacker_news/ui/news/ArticleListPage.dart'; 7 | import 'package:kiwi/kiwi.dart'; 8 | 9 | class ArticleListModule extends Module { 10 | @override 11 | void registerOn(Container container) { 12 | // View 13 | container.registerInstance(ArticleViewModelMapper()); 14 | container.registerInstance( 15 | ArticleListPageState(container.resolve())); 16 | // Presenter 17 | container.registerInstance(ArticleListPresenter( 18 | container.resolve(), 19 | container.resolve(), 20 | container.resolve())); 21 | } 22 | } -------------------------------------------------------------------------------- /hacker_news/lib/ui/injection/Injector.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/ui/injection/Module.dart'; 2 | import 'package:kiwi/kiwi.dart'; 3 | 4 | final injector = Injector._internal(); 5 | 6 | class Injector { 7 | final Container container = Container(); 8 | 9 | Injector._internal(); 10 | 11 | void inject(List modules) { 12 | modules.forEach((module) => module.registerOn(container)); 13 | } 14 | 15 | T resolve([String name]) => container.resolve(name); 16 | } -------------------------------------------------------------------------------- /hacker_news/lib/ui/injection/Module.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:kiwi/kiwi.dart'; 3 | 4 | abstract class Module { 5 | 6 | void registerOn(Container container); 7 | } 8 | -------------------------------------------------------------------------------- /hacker_news/lib/ui/mapper/ArticleViewModelMapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/presentation/model/ArticleView.dart'; 2 | import 'package:hacker_news/ui/mapper/Mapper.dart'; 3 | import 'package:hacker_news/ui/model/ArticleViewModel.dart'; 4 | 5 | /// Map a [ArticleView] to and from a [ArticleViewModel] instance 6 | /// when data is moving between this layer and the Presentation layer 7 | class ArticleViewModelMapper implements Mapper { 8 | @override 9 | ArticleViewModel mapToViewModel(ArticleView type) { 10 | return ArticleViewModel(type.title, type.type, type.descendants.toString()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /hacker_news/lib/ui/mapper/Mapper.dart: -------------------------------------------------------------------------------- 1 | /// Interface for model mappers. It provides helper methods 2 | /// that facilitate retrieving of models from outer layers 3 | abstract class Mapper { 4 | VM mapToViewModel(V type); 5 | } -------------------------------------------------------------------------------- /hacker_news/lib/ui/model/ArticleViewModel.dart: -------------------------------------------------------------------------------- 1 | /// Representation for a [ArticleViewModel] fetched from an external layer data source 2 | class ArticleViewModel { 3 | String title; 4 | String type; 5 | String descendants; 6 | 7 | ArticleViewModel(this.title, this.type, this.descendants); 8 | } -------------------------------------------------------------------------------- /hacker_news/lib/ui/news/ArticleListPage.dart: -------------------------------------------------------------------------------- 1 | import 'package:hacker_news/presentation/model/ArticleView.dart'; 2 | import 'package:hacker_news/presentation/news/ArticleListContract.dart'; 3 | import 'package:hacker_news/presentation/news/ArticleListPresenter.dart'; 4 | import 'package:hacker_news/ui/injection/Injector.dart'; 5 | import 'package:hacker_news/ui/mapper/ArticleViewModelMapper.dart'; 6 | import 'package:hacker_news/ui/model/ArticleViewModel.dart'; 7 | import 'package:hacker_news/ui/news/ArticleListView.dart'; 8 | import 'package:flutter/material.dart'; 9 | 10 | class ArticleListPage extends StatefulWidget { 11 | ArticleListPage({Key key, this.title}) : super(key: key); 12 | 13 | final String title; 14 | 15 | @override 16 | ArticleListPageState createState() { 17 | var view = injector.resolve(); 18 | var presenter = injector.resolve(); 19 | view.setPresenter(presenter); 20 | 21 | return view; 22 | } 23 | } 24 | 25 | class ArticleListPageState extends State implements View { 26 | bool _isLoading = false; 27 | var articles = List(); 28 | Presenter presenter; 29 | ArticleViewModelMapper mapper; 30 | 31 | ArticleListPageState(this.mapper); 32 | 33 | @override 34 | void setPresenter(presenter) { 35 | this.presenter = presenter; 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return Scaffold( 41 | appBar: AppBar( 42 | title: Text(widget.title), 43 | ), 44 | body: _buildCenter(context), 45 | ); 46 | } 47 | 48 | @override 49 | void initState() { 50 | super.initState(); 51 | presenter.start(); 52 | } 53 | 54 | @override 55 | void dispose() { 56 | presenter.stop(); 57 | super.dispose(); 58 | } 59 | 60 | @override 61 | void showProgress() { 62 | setState(() { 63 | _isLoading = true; 64 | }); 65 | } 66 | 67 | @override 68 | void hideProgress() { 69 | setState(() { 70 | _isLoading = false; 71 | }); 72 | } 73 | 74 | @override 75 | void updateArticles(List articles) { 76 | this.articles = articles.map((it) => mapper.mapToViewModel(it)).toList(); 77 | } 78 | 79 | Widget _buildCenter(BuildContext context) { 80 | if (_isLoading) { 81 | return Center(child: CircularProgressIndicator()); 82 | } else { 83 | return Center(child: ArticleListView(this.articles)); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /hacker_news/lib/ui/news/ArticleListView.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hacker_news/ui/model/ArticleViewModel.dart'; 3 | 4 | class ArticleListView extends StatelessWidget { 5 | final List articles; 6 | 7 | ArticleListView(this.articles); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return ListView( 12 | children: articles 13 | .map((article) => Padding( 14 | key: Key(article.title), 15 | padding: 16 | const EdgeInsets.symmetric(horizontal: 4.0, vertical: 12.0), 17 | child: ExpansionTile( 18 | title: Text(article.title ?? '[null]', 19 | style: TextStyle(fontSize: 24.0)), 20 | children: [ 21 | Padding( 22 | padding: const EdgeInsets.symmetric(horizontal: 16.0), 23 | child: Column( 24 | children: [ 25 | Row( 26 | mainAxisAlignment: MainAxisAlignment.start, 27 | children: [ 28 | Text('${article.descendants} comments'), 29 | SizedBox(width: 16.0), 30 | IconButton( 31 | icon: Icon(Icons.launch), 32 | onPressed: () {}, 33 | ) 34 | ], 35 | ), 36 | ], 37 | ), 38 | ), 39 | ], 40 | ), 41 | )) 42 | .toList(), 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /hacker_news/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: hacker_news 2 | description: A Flutter Application in Clean Architecture 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 | # Read more about versioning at semver.org. 10 | version: 1.0.0+1 11 | 12 | environment: 13 | sdk: ">=2.0.0-dev.68.0 <3.0.0" 14 | 15 | dependencies: 16 | http: 0.12.0 17 | shared_preferences: ^0.4.3 18 | sqflite: ^1.0.0 19 | path_provider: ^0.4.1 20 | kiwi: ^0.1.0 21 | 22 | flutter: 23 | sdk: flutter 24 | 25 | # The following adds the Cupertino Icons font to your application. 26 | # Use with the CupertinoIcons class for iOS style icons. 27 | cupertino_icons: ^0.1.2 28 | 29 | dev_dependencies: 30 | flutter_test: 31 | sdk: flutter 32 | 33 | 34 | # For information on the generic Dart part of this file, see the 35 | # following page: https://www.dartlang.org/tools/pub/pubspec 36 | 37 | # The following section is specific to Flutter. 38 | flutter: 39 | 40 | # The following line ensures that the Material Icons font is 41 | # included with your application, so that you can use the icons in 42 | # the material Icons class. 43 | uses-material-design: true 44 | 45 | # To add assets to your application, add an assets section, like this: 46 | # assets: 47 | # - images/a_dot_burr.jpeg 48 | # - images/a_dot_ham.jpeg 49 | 50 | # An image asset can refer to one or more resolution-specific "variants", see 51 | # https://flutter.io/assets-and-images/#resolution-aware. 52 | 53 | # For details regarding adding assets from package dependencies, see 54 | # https://flutter.io/assets-and-images/#from-packages 55 | 56 | # To add custom fonts to your application, add a fonts section here, 57 | # in this "flutter" section. Each entry in this list should have a 58 | # "family" key with the font family name, and a "fonts" key with a 59 | # list giving the asset and other descriptors for the font. For 60 | # example: 61 | # fonts: 62 | # - family: Schyler 63 | # fonts: 64 | # - asset: fonts/Schyler-Regular.ttf 65 | # - asset: fonts/Schyler-Italic.ttf 66 | # style: italic 67 | # - family: Trajan Pro 68 | # fonts: 69 | # - asset: fonts/TrajanPro.ttf 70 | # - asset: fonts/TrajanPro_Bold.ttf 71 | # weight: 700 72 | # 73 | # For details regarding fonts from package dependencies, 74 | # see https://flutter.io/custom-fonts/#from-packages 75 | -------------------------------------------------------------------------------- /hacker_news/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:hacker_news/ui/HackerNewsApplication.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(HackerNewsApplication()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LostInIreland/Flutter-Clean-Architecture/927c7c66d70523f070f46971c315ece9d448fd44/sample.png --------------------------------------------------------------------------------