├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── basic_architecture │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets └── images │ ├── 13028129.jpg │ └── flutter-logo.png ├── devtools_options.yaml ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h └── RunnerTests │ └── RunnerTests.swift ├── l10n.yaml ├── lib ├── App │ ├── app.dart │ └── app_preferences.dart ├── Data │ ├── data_source │ │ ├── remote_data_source.dart │ │ └── remote_data_source_imp.dart │ ├── network │ │ ├── api_client.dart │ │ ├── api_endpoint.dart │ │ ├── api_provider.dart │ │ ├── api_sample_data_service.dart │ │ ├── api_sample_data_service.g.dart │ │ ├── api_service.dart │ │ ├── api_service.g.dart │ │ └── auth_token_dio_interceptor.dart │ ├── repository │ │ ├── authentication_repository_imp.dart │ │ ├── member_repository_imp.dart │ │ └── sample_data_repository_imp.dart │ ├── responses │ │ ├── authentication_response.dart │ │ ├── authentication_response.g.dart │ │ ├── base_response.dart │ │ ├── member_response.dart │ │ ├── member_response.g.dart │ │ ├── sample_data_response.dart │ │ ├── sample_data_response.g.dart │ │ ├── subscription_key_response.dart │ │ └── subscription_key_response.g.dart │ └── translator │ │ └── translator.dart ├── Domain │ ├── models │ │ ├── authentication.dart │ │ ├── member_info.dart │ │ ├── sample_data.dart │ │ └── subscription_key.dart │ ├── repository │ │ ├── authentication_repository.dart │ │ ├── member_repository.dart │ │ └── sample_data_repository.dart │ ├── request │ │ ├── login_request.dart │ │ └── register_request.dart │ └── usecase │ │ ├── base_usecase.dart │ │ ├── detail_load_sample_data_usecase.dart │ │ ├── load_sample_data_usecase.dart │ │ ├── login_usecase.dart │ │ ├── logout_usecase.dart │ │ ├── member_info_usecase.dart │ │ └── subscription_key_info_usecase.dart ├── Injectable │ ├── configurations.config.dart │ └── configurations.dart ├── Presentation │ ├── authentication │ │ └── bloc │ │ │ ├── authentication_bloc.dart │ │ │ ├── authentication_event.dart │ │ │ ├── authentication_state.dart │ │ │ └── member_viewmodel.dart │ ├── component │ │ └── placeholders.dart │ ├── home │ │ ├── bloc │ │ │ ├── sample_data_bloc.dart │ │ │ ├── sample_data_event.dart │ │ │ └── sample_data_state.dart │ │ └── view │ │ │ ├── app_view.dart │ │ │ ├── desktop_home_view.dart │ │ │ └── mobile_home_view.dart │ ├── login │ │ ├── bloc │ │ │ ├── login_bloc.dart │ │ │ ├── login_event.dart │ │ │ └── login_state.dart │ │ ├── forms │ │ │ ├── id_input.dart │ │ │ └── password_input.dart │ │ └── view │ │ │ └── login_view.dart │ ├── routes_manager.dart │ ├── splash │ │ └── splash.dart │ └── subscription_info │ │ ├── bloc │ │ ├── subscription_info_bloc.dart │ │ ├── subscription_info_event.dart │ │ └── subscription_info_state.dart │ │ └── view │ │ └── subscription_info_view.dart ├── config.dart ├── l10n │ └── arb │ │ ├── app_en.arb │ │ └── app_ko.arb └── main.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements └── RunnerTests │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Symbolication related 35 | app.*.symbols 36 | 37 | # Obfuscation related 38 | app.*.map.json 39 | 40 | # Android Studio will place build artifacts here 41 | /android/app/debug 42 | /android/app/profile 43 | /android/app/release 44 | -------------------------------------------------------------------------------- /.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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 17 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 18 | - platform: android 19 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 20 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 21 | - platform: ios 22 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 23 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 24 | - platform: linux 25 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 26 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 27 | - platform: macos 28 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 29 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 30 | - platform: web 31 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 32 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 33 | - platform: windows 34 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 35 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter basic clean architecture demo app 2 | 3 | ### This project is based on Flutter and implements and explains simple functions aimed at basic Clean Architecture design. 4 | ### 이 프로젝트는 Flutter 기반으로 기본적인 Clean Architecture 설계를 목표로한 간단한 기능이 구현 되어 있고, 설명 하고 있습니다. 5 | 6 | - blog post : [Flutter - Clean Architecture 적용해보기](https://blog.arong.info/flutter/2023/11/29/Flutter-Clean-Architecture-%EC%A0%81%EC%9A%A9%ED%95%B4%EB%B3%B4%EA%B8%B0.html) 7 | 8 | Project Architecture 9 | - 10 | ![플러터_클린아키텍처_구조](https://github.com/tyeom/flutter_basic_architecture/assets/13028129/97b2e130-733a-43b0-8317-cf1dfd24d319) 11 | 12 | > **※ Incorrect orientation of the 'Import to' arrow in the architectural diagram.**
13 | > ~[Presentaion Module] Bloc -> [Domain Module] Use Case~ → [Domain Module] Use Case -> [Presentaion Module] Bloc
14 | > ~[Data Module] Translator -> [Domain Module] Model~ → [Domain Module] Model -> [Data Module] Translator
15 | 16 | Project solution structure 17 | - 18 | 19 | ├─**App** - App initial settings
20 | ├─**Data**
21 | │ ├─**data_source** - API request
22 | │ ├─**network** - http request module
23 | │ ├─**repository** - Implementation of actual data request processing
24 | │ ├─**responses** - data entity
25 | │ └─**translator** - Domain layer Model Mapper
26 | ├─**Domain**
27 | │ ├─**models** - Data Model
28 | │ ├─**repository** - Business logic abstraction
29 | │ ├─**request** - Data request information
30 | │ └─**usecase** - Either Concepts (Left - Failure) / (Right - Success), UseCase definition
31 | ├─**Injectable** - Initialize injectable
32 | ├─**l10n**
33 | │ └─arb
34 | └─**Presentation** - UI(Login, Data List, Simple page routing, skeleton loading)
35 | ├─**authentication**
36 | │ └─**bloc** - Authentication-related UI business logic
37 | ├─**component** - common widgets
38 | ├─**home**
39 | │ ├─**bloc** - Main home UI business logic
40 | │ └─**view** - Main home UI
41 | ├─**login**
42 | │ ├─**bloc** - Login UI business logic
43 | │ ├─**forms** - Login user input forms (used in the forms package)
44 | │ └─**view** - Login UI
45 | ├─**splash** - splash UI
46 | └─**subscription_info**
47 | ├─**bloc**
48 | └─**view**
49 | 50 | Packages 51 | - 52 | 53 | - get_it 54 | - injectable 55 | - flutter_bloc 56 | - dio 57 | - pretty_dio_logger 58 | - equatable 59 | - dartz 60 | - json_annotation 61 | - json_serializable 62 | - retrofit 63 | - formz 64 | - shared_preferences 65 | - flutter_secure_storage 66 | - flutter_speed_dial 67 | - bottom_sheet 68 | - shimmer 69 | 70 |
71 | 72 | > **This project implements various functions in basic app implementation.** 73 | 74 | > **이 프로젝트는 기본적인 앱 구현에 있어 필요한 다양한 기능들이 구현 되어 있습니다.**
75 | > (반응형 UI처리, skeleton loading 효과, 다국어 처리, BLoC를 통한 상태 관리, Dio Interceptor를 통한 API Access token 인증 처리, API Access token 만료시 재발급 로직 설명 등) 76 | 77 | *** 78 | 79 | how to use tha app? 80 | - 81 | 82 | ![Clean_Architecture_Flutter](https://github.com/tyeom/flutter_basic_architecture/assets/13028129/57450296-226d-48d6-bb61-b96dd614dfd9) 83 | 84 | ### for *login* use the following data 85 | ``` 86 | { 87 | "Id":"test", 88 | "Password":"1234" 89 | } 90 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "com.example.basic_architecture" 27 | compileSdkVersion flutter.compileSdkVersion 28 | ndkVersion flutter.ndkVersion 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | 39 | sourceSets { 40 | main.java.srcDirs += 'src/main/kotlin' 41 | } 42 | 43 | defaultConfig { 44 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 45 | applicationId "com.example.basic_architecture" 46 | // You can update the following values to match your application needs. 47 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 48 | minSdkVersion flutter.minSdkVersion 49 | targetSdkVersion flutter.targetSdkVersion 50 | versionCode flutterVersionCode.toInteger() 51 | versionName flutterVersionName 52 | } 53 | 54 | buildTypes { 55 | release { 56 | // TODO: Add your own signing config for the release build. 57 | // Signing with the debug keys for now, so `flutter run --release` works. 58 | signingConfig signingConfigs.debug 59 | } 60 | } 61 | } 62 | 63 | flutter { 64 | source '../..' 65 | } 66 | 67 | dependencies {} 68 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/basic_architecture/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.basic_architecture 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | google() 16 | mavenCentral() 17 | } 18 | } 19 | 20 | rootProject.buildDir = '../build' 21 | subprojects { 22 | project.buildDir = "${rootProject.buildDir}/${project.name}" 23 | } 24 | subprojects { 25 | project.evaluationDependsOn(':app') 26 | } 27 | 28 | tasks.register("clean", Delete) { 29 | delete rootProject.buildDir 30 | } 31 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | repositories { 14 | google() 15 | mavenCentral() 16 | gradlePluginPortal() 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 21 | } 22 | } 23 | 24 | plugins { 25 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 26 | id "com.android.application" version "7.3.0" apply false 27 | } 28 | 29 | include ":app" 30 | -------------------------------------------------------------------------------- /assets/images/13028129.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/assets/images/13028129.jpg -------------------------------------------------------------------------------- /assets/images/flutter-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/assets/images/flutter-logo.png -------------------------------------------------------------------------------- /devtools_options.yaml: -------------------------------------------------------------------------------- 1 | extensions: 2 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Basic Architecture 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | basic_architecture 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/l10n/arb 2 | template-arb-file: app_en.arb 3 | output-localization-file: app_localizations.dart -------------------------------------------------------------------------------- /lib/App/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Injectable/configurations.dart'; 2 | import 'package:basic_architecture/Presentation/authentication/bloc/authentication_bloc.dart'; 3 | import 'package:basic_architecture/Presentation/home/bloc/sample_data_bloc.dart'; 4 | import 'package:basic_architecture/Presentation/routes_manager.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:flutter_localizations/flutter_localizations.dart'; 8 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 9 | import 'package:basic_architecture/config.dart'; 10 | 11 | class MyApp extends StatelessWidget { 12 | const MyApp({super.key}); 13 | 14 | @override 15 | Widget build(BuildContext context) => MultiBlocProvider( 16 | providers: [ 17 | BlocProvider( 18 | create: (BuildContext context) => getIt() 19 | ..add( 20 | AuthenticationStatusChanged(AuthenticationStatus.loading)), 21 | ), 22 | ], 23 | child: MaterialApp( 24 | title: 'Clean Architecture in Flutter Demo App', 25 | debugShowCheckedModeBanner: false, 26 | theme: ThemeData( 27 | primarySwatch: Colors.blue, 28 | ), 29 | localizationsDelegates: const [ 30 | AppLocalizations.delegate, 31 | GlobalMaterialLocalizations.delegate, 32 | GlobalWidgetsLocalizations.delegate, 33 | GlobalCupertinoLocalizations.delegate, 34 | ], 35 | supportedLocales: Language.values.map((e) => e.locale).toList(), 36 | locale: Language.ko.locale, 37 | onGenerateRoute: RouteGenerator.getRoute, 38 | initialRoute: Routes.splashRoute, 39 | )); 40 | } 41 | -------------------------------------------------------------------------------- /lib/App/app_preferences.dart: -------------------------------------------------------------------------------- 1 | import 'package:injectable/injectable.dart'; 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | const String PREFS_KEY_USER_LOGIN = "USER_LOGIN"; 5 | 6 | class AppPreferences { 7 | final SharedPreferences _sharedPreferences; 8 | 9 | AppPreferences(this._sharedPreferences); 10 | 11 | /// 로그인 완료시, 추후 자동 로그인 사용 12 | bool? get userToken => _sharedPreferences.getBool(PREFS_KEY_USER_LOGIN); 13 | 14 | Future login() => 15 | _sharedPreferences.setBool(PREFS_KEY_USER_LOGIN, true); 16 | 17 | Future logout() async { 18 | await _sharedPreferences.remove(PREFS_KEY_USER_LOGIN); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/Data/data_source/remote_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/responses/authentication_response.dart'; 2 | import 'package:basic_architecture/Data/responses/member_response.dart'; 3 | import 'package:basic_architecture/Data/responses/sample_data_response.dart'; 4 | import 'package:basic_architecture/Data/responses/subscription_key_response.dart'; 5 | import 'package:basic_architecture/Domain/request/login_request.dart'; 6 | import 'package:basic_architecture/Domain/request/register_request.dart'; 7 | 8 | abstract class RemoteDataSource { 9 | Future login(LoginRequest loginRequest); 10 | Future logout(); 11 | Future register(RegisterRequest registerRequest); 12 | Future getMemberInfo(); 13 | Future> getSampleData(); 14 | Future getDetailSampleData(int id); 15 | Future getSubscriptionKeyResponse(); 16 | } 17 | -------------------------------------------------------------------------------- /lib/Data/data_source/remote_data_source_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/data_source/remote_data_source.dart'; 2 | import 'package:basic_architecture/Data/network/api_sample_data_service.dart'; 3 | import 'package:basic_architecture/Data/network/api_service.dart'; 4 | import 'package:basic_architecture/Data/responses/authentication_response.dart'; 5 | import 'package:basic_architecture/Data/responses/member_response.dart'; 6 | import 'package:basic_architecture/Data/responses/sample_data_response.dart'; 7 | import 'package:basic_architecture/Data/responses/subscription_key_response.dart'; 8 | import 'package:basic_architecture/Domain/request/login_request.dart'; 9 | import 'package:basic_architecture/Domain/request/register_request.dart'; 10 | 11 | class RemoteDataSourceImp implements RemoteDataSource { 12 | final ApiService _apiService; 13 | final ApiSampleDataService _apiSampleDataService; 14 | 15 | RemoteDataSourceImp(this._apiService, this._apiSampleDataService); 16 | 17 | @override 18 | Future login(LoginRequest loginRequest) async { 19 | return await _apiService.login(loginRequest.id, loginRequest.password); 20 | } 21 | 22 | @override 23 | Future logout() async { 24 | return await _apiService.logout(); 25 | } 26 | 27 | @override 28 | Future register(RegisterRequest registerRequest) async { 29 | return await _apiService.register( 30 | registerRequest.id, 31 | registerRequest.password, 32 | registerRequest.role, 33 | registerRequest.name, 34 | registerRequest.email, 35 | registerRequest.tel); 36 | } 37 | 38 | @override 39 | Future getMemberInfo() async { 40 | return await _apiService.getMemberInfo(); 41 | } 42 | 43 | @override 44 | Future> getSampleData() async { 45 | return await _apiSampleDataService.getSampleData(); 46 | } 47 | 48 | @override 49 | Future getDetailSampleData(int id) async { 50 | return await _apiSampleDataService.getDetailSampleData(id); 51 | } 52 | 53 | @override 54 | Future getSubscriptionKeyResponse() async { 55 | return await _apiService.getSubscriptionKeyInfo(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/Data/network/api_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app_preferences.dart'; 2 | import 'package:basic_architecture/Data/network/api_endpoint.dart'; 3 | import 'package:basic_architecture/Data/network/api_provider.dart'; 4 | 5 | class ApiClient { 6 | final bool enableLogging; 7 | late final ApiProviderFactory apiProvider; 8 | 9 | ApiClient(ApiType apiType, {required this.enableLogging}) { 10 | apiProvider = ApiProviderFactory(apiType, enableLogging); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/Data/network/api_endpoint.dart: -------------------------------------------------------------------------------- 1 | class ApiEndpoint { 2 | static const String baseUrl = 'https://api.namicro.co.kr'; 3 | static const String publicApi = '/public'; 4 | static const String privateApi = '/private'; 5 | 6 | static const String baseUrlSampleData = 'http://arong.info:7003'; 7 | static const String sampleDataApi = '/posts'; 8 | } 9 | -------------------------------------------------------------------------------- /lib/Data/network/api_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/network/api_endpoint.dart'; 2 | import 'package:basic_architecture/Data/network/auth_token_dio_interceptor.dart'; 3 | import 'package:dio/dio.dart'; 4 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 5 | import 'package:pretty_dio_logger/pretty_dio_logger.dart'; 6 | 7 | enum ApiType { base, sampleData } 8 | 9 | abstract class ApiProviderFactory { 10 | Dio get getDio; 11 | 12 | factory ApiProviderFactory(ApiType type, bool enableLogger, 13 | {BaseOptions? options}) { 14 | switch (type) { 15 | case ApiType.base: 16 | return ApiProvider(enableLogger, options: options); 17 | case ApiType.sampleData: 18 | return SampleDataApiProvider(enableLogger, options: options); 19 | } 20 | } 21 | } 22 | 23 | /// 기본 RestFul API 24 | /// Basic RestFul API 25 | class ApiProvider implements ApiProviderFactory { 26 | static const int apiTimeOut = 60000; 27 | static late Dio dio; 28 | 29 | bool enableLogger; 30 | 31 | ApiProvider(this.enableLogger, {BaseOptions? options}) { 32 | final dioInstance = Dio(options ?? BaseOptions() 33 | ..baseUrl = ApiEndpoint.baseUrl 34 | ..connectTimeout = const Duration(milliseconds: apiTimeOut) 35 | ..receiveTimeout = const Duration(milliseconds: apiTimeOut) 36 | ..headers = { 37 | 'Content-Type': 'application/json; charset=utf-8', 38 | 'accept': 'application/json', 39 | }); 40 | 41 | if (enableLogger) { 42 | dioInstance.interceptors.add(PrettyDioLogger( 43 | requestHeader: true, 44 | requestBody: true, 45 | responseBody: true, 46 | responseHeader: false, 47 | error: true, 48 | compact: true, 49 | maxWidth: 90)); 50 | } 51 | 52 | const storage = FlutterSecureStorage(); 53 | dioInstance.interceptors.add(AuthTokenDioInterceptor(storage: storage)); 54 | dio = dioInstance; 55 | } 56 | 57 | @override 58 | Dio get getDio => dio; 59 | } 60 | 61 | /// 테스트용 데이터 Web API 62 | /// Sample data call web api 63 | class SampleDataApiProvider implements ApiProviderFactory { 64 | static const int apiTimeOut = 60000; 65 | static late Dio dio; 66 | 67 | bool enableLogger; 68 | 69 | SampleDataApiProvider(this.enableLogger, {BaseOptions? options}) { 70 | final dioInstance = Dio(options ?? BaseOptions() 71 | ..baseUrl = ApiEndpoint.baseUrlSampleData 72 | ..connectTimeout = const Duration(milliseconds: apiTimeOut) 73 | ..receiveTimeout = const Duration(milliseconds: apiTimeOut) 74 | ..headers = { 75 | 'Content-Type': 'application/json; charset=utf-8', 76 | 'accept': 'application/json', 77 | }); 78 | 79 | if (enableLogger) { 80 | dioInstance.interceptors.add(PrettyDioLogger( 81 | requestHeader: true, 82 | requestBody: true, 83 | responseBody: true, 84 | responseHeader: false, 85 | error: true, 86 | compact: true, 87 | maxWidth: 90)); 88 | } 89 | 90 | dio = dioInstance; 91 | } 92 | 93 | @override 94 | Dio get getDio => dio; 95 | } 96 | -------------------------------------------------------------------------------- /lib/Data/network/api_sample_data_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/network/api_endpoint.dart'; 2 | import 'package:basic_architecture/Data/responses/sample_data_response.dart'; 3 | import 'package:dio/dio.dart'; 4 | import 'package:retrofit/retrofit.dart'; 5 | 6 | part 'api_sample_data_service.g.dart'; 7 | 8 | @RestApi() 9 | abstract class ApiSampleDataService { 10 | factory ApiSampleDataService(final Dio dio) = _ApiSampleDataService; 11 | 12 | /// 샘플 데이터 정보 요청 13 | @GET("${ApiEndpoint.sampleDataApi}") 14 | Future> getSampleData(); 15 | 16 | /// 샘플 데이터 상세 정보 요청 17 | @GET("${ApiEndpoint.sampleDataApi}/{id}") 18 | Future getDetailSampleData( 19 | @Path("id") int id, 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /lib/Data/network/api_sample_data_service.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'api_sample_data_service.dart'; 4 | 5 | // ************************************************************************** 6 | // RetrofitGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers 10 | 11 | class _ApiSampleDataService implements ApiSampleDataService { 12 | _ApiSampleDataService( 13 | this._dio, { 14 | this.baseUrl, 15 | }); 16 | 17 | final Dio _dio; 18 | 19 | String? baseUrl; 20 | 21 | @override 22 | Future> getSampleData() async { 23 | const _extra = {}; 24 | final queryParameters = {}; 25 | final _headers = {}; 26 | final Map? _data = null; 27 | final _result = await _dio 28 | .fetch>(_setStreamType>(Options( 29 | method: 'GET', 30 | headers: _headers, 31 | extra: _extra, 32 | ) 33 | .compose( 34 | _dio.options, 35 | '/posts', 36 | queryParameters: queryParameters, 37 | data: _data, 38 | ) 39 | .copyWith( 40 | baseUrl: _combineBaseUrls( 41 | _dio.options.baseUrl, 42 | baseUrl, 43 | )))); 44 | var value = _result.data! 45 | .map((dynamic i) => 46 | SampleDataResponse.fromJson(i as Map)) 47 | .toList(); 48 | return value; 49 | } 50 | 51 | @override 52 | Future getDetailSampleData(int id) async { 53 | const _extra = {}; 54 | final queryParameters = {}; 55 | final _headers = {}; 56 | final Map? _data = null; 57 | final _result = await _dio 58 | .fetch>(_setStreamType(Options( 59 | method: 'GET', 60 | headers: _headers, 61 | extra: _extra, 62 | ) 63 | .compose( 64 | _dio.options, 65 | '/posts/${id}', 66 | queryParameters: queryParameters, 67 | data: _data, 68 | ) 69 | .copyWith( 70 | baseUrl: _combineBaseUrls( 71 | _dio.options.baseUrl, 72 | baseUrl, 73 | )))); 74 | final value = SampleDataResponse.fromJson(_result.data!); 75 | return value; 76 | } 77 | 78 | RequestOptions _setStreamType(RequestOptions requestOptions) { 79 | if (T != dynamic && 80 | !(requestOptions.responseType == ResponseType.bytes || 81 | requestOptions.responseType == ResponseType.stream)) { 82 | if (T == String) { 83 | requestOptions.responseType = ResponseType.plain; 84 | } else { 85 | requestOptions.responseType = ResponseType.json; 86 | } 87 | } 88 | return requestOptions; 89 | } 90 | 91 | String _combineBaseUrls( 92 | String dioBaseUrl, 93 | String? baseUrl, 94 | ) { 95 | if (baseUrl == null || baseUrl.trim().isEmpty) { 96 | return dioBaseUrl; 97 | } 98 | 99 | final url = Uri.parse(baseUrl); 100 | 101 | if (url.isAbsolute) { 102 | return url.toString(); 103 | } 104 | 105 | return Uri.parse(dioBaseUrl).resolveUri(url).toString(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /lib/Data/network/api_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/network/api_endpoint.dart'; 2 | import 'package:basic_architecture/Data/responses/authentication_response.dart'; 3 | import 'package:basic_architecture/Data/responses/member_response.dart'; 4 | import 'package:basic_architecture/Data/responses/subscription_key_response.dart'; 5 | import 'package:dio/dio.dart'; 6 | import 'package:retrofit/http.dart' as http; 7 | import 'package:retrofit/retrofit.dart'; 8 | 9 | part 'api_service.g.dart'; 10 | 11 | @RestApi() 12 | abstract class ApiService { 13 | factory ApiService(final Dio dio) = _ApiService; 14 | 15 | /// 로그인 요청 16 | @POST("${ApiEndpoint.publicApi}/login") 17 | Future login( 18 | @Field("Id") String id, @Field("Password") String password); 19 | 20 | /// 로그아웃 요청 21 | @GET("${ApiEndpoint.publicApi}/Logout") 22 | Future logout(); 23 | 24 | /// 회원 가입 요청 25 | @GET("${ApiEndpoint.publicApi}/Register") 26 | Future register( 27 | @Field("id") String id, 28 | @Field("password") String password, 29 | @Field("role") int role, 30 | @Field("name") String name, 31 | @Field("email") String? email, 32 | @Field("tel") String? tel, 33 | ); 34 | 35 | /// 유저 정보 요청 36 | @GET("${ApiEndpoint.privateApi}/MemberInfo") 37 | @http.Headers({'accessToken': 'true'}) 38 | Future getMemberInfo(); 39 | 40 | /// 구독 키 정보 정보 요청 41 | @GET("${ApiEndpoint.privateApi}/SubscriptionKey") 42 | @http.Headers({'accessToken': 'true'}) 43 | Future getSubscriptionKeyInfo(); 44 | } 45 | -------------------------------------------------------------------------------- /lib/Data/network/auth_token_dio_interceptor.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 3 | 4 | const String ACCESS_TOKEN_KEY = 'authToken'; 5 | 6 | /// Dio Request, Response, Error시 가로채기 7 | /// Request시 onRequest를 가로채어, accessToken이 필요한 API Url인 경우 헤더에 accessToken을 대체해서 Request 처리 한다. 8 | class AuthTokenDioInterceptor extends Interceptor { 9 | final FlutterSecureStorage storage; 10 | 11 | AuthTokenDioInterceptor({required this.storage}); 12 | 13 | @override 14 | void onRequest( 15 | RequestOptions options, RequestInterceptorHandler handler) async { 16 | print('[Dio REQ] [${options.method}] ${options.uri}'); 17 | 18 | // 요청 헤더 19 | // 헤더에 accessToken가 있는 경우 인증 토큰 필요 API 20 | // ApiService 클래스에 Headers 어노테이션으로 정의 되어 있음. 21 | if (options.headers['accessToken'] == 'true') { 22 | // 헤더 삭제 23 | options.headers.remove('accessToken'); 24 | 25 | // 실제 토큰 대체 26 | final token = await storage.read(key: ACCESS_TOKEN_KEY); 27 | options.headers.addAll({'authorization': 'Bearer $token'}); 28 | } 29 | 30 | super.onRequest(options, handler); 31 | } 32 | 33 | @override 34 | void onResponse(Response response, ResponseInterceptorHandler handler) { 35 | print( 36 | '[Dio RES] [${response.requestOptions.method}] ${response.requestOptions.uri}'); 37 | 38 | super.onResponse(response, handler); 39 | } 40 | 41 | @override 42 | void onError(DioException err, ErrorInterceptorHandler handler) async { 43 | print('[Dio ERR] [${err.requestOptions.method}] ${err.requestOptions.uri}'); 44 | 45 | // 인증 처리가 AccessToken / RefreshToken 사용시 46 | // 여기서 인증 오류(Status 401)인 경우 AccessToken 만료시 RefreshToken 으로 AccessToken 재발급 처리를 한다. 47 | // AccessToken 재발급 후 AccessToken과 RefreshToken을 secure storage에 다시 기록후 48 | // 헤더에 AccessToken을 대체하고 다시 요청한다.(fetch) 49 | 50 | // When using AccessToken / RefreshToken for authentication processing 51 | // If there is an authentication error (Status 401) here, 52 | // the AccessToken is reissued using RefreshToken when the AccessToken expires. 53 | 54 | /***********************************************/ 55 | 56 | // final isStatus401 = err.response?.statusCode == 401; 57 | // final isPathRefresh = err.requestOptions.path == '/auth/token'; 58 | 59 | // // AccessToken 재발급 60 | // if (isStatus401 && !isPathRefresh) { 61 | // final dio = Dio(); 62 | // try { 63 | // final resp = await dio.post( 64 | // 'AccessToken 재발급 url', 65 | // options: Options( 66 | // headers: {'authorization': 'Bearer $refreshToken'}, 67 | // ), 68 | // ); 69 | 70 | // // 재발급 받은 AccessToken 등록 71 | // final accessToken = resp.data['accessToken']; 72 | 73 | // // AccessToken 만료로 요청 실패 했던 옵션 74 | // final options = err.requestOptions; 75 | // // 재발급 AccessToken 으로 교체 76 | // options.headers.addAll({'authorization': 'Bearer $accessToken'}); 77 | // // secure storage에 다시 보관 78 | // await storage.write(key: ACCESS_TOKEN_KEY, value: accessToken); 79 | 80 | // final response = await dio.fetch(options); 81 | 82 | // return handler.resolve(response); 83 | // } catch (e) { 84 | // return handler.reject(err); 85 | // } 86 | // } 87 | 88 | super.onError(err, handler); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/Data/repository/authentication_repository_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/data_source/remote_data_source.dart'; 2 | import 'package:basic_architecture/Data/network/auth_token_dio_interceptor.dart'; 3 | import 'package:basic_architecture/Data/responses/authentication_response.dart'; 4 | import 'package:basic_architecture/Domain/models/authentication.dart'; 5 | import 'package:basic_architecture/Domain/repository/authentication_repository.dart'; 6 | import 'package:basic_architecture/Domain/request/login_request.dart'; 7 | import 'package:basic_architecture/Domain/request/register_request.dart'; 8 | import 'package:basic_architecture/Data/translator/translator.dart'; 9 | import 'package:dartz/dartz.dart'; 10 | import 'package:dio/dio.dart'; 11 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 12 | import 'package:injectable/injectable.dart'; 13 | 14 | @LazySingleton(as: AuthenticationRepository) 15 | class AuthenticationRepositoryImp implements AuthenticationRepository { 16 | final RemoteDataSource _remote; 17 | 18 | AuthenticationRepositoryImp(this._remote); 19 | 20 | @override 21 | Future> forgotPassword(String id) { 22 | // TODO: implement forgotPassword 23 | throw UnimplementedError(); 24 | } 25 | 26 | @override 27 | Future> login( 28 | LoginRequest loginRequest) async { 29 | try { 30 | final AuthenticationResponse response = await _remote.login(loginRequest); 31 | // if (response.status == 200) { 32 | // return Right(response.toDomain()); 33 | // } else { 34 | // return Left(response.message ?? '인증 요청 - 서버 응답 오류 01'); 35 | // } 36 | var authentication = response.toDomain(); 37 | 38 | const storage = FlutterSecureStorage(); 39 | await storage.write(key: ACCESS_TOKEN_KEY, value: authentication.token); 40 | 41 | return Right(authentication); 42 | } on DioException catch (ex) { 43 | if (ex.response != null) { 44 | if (ex.response!.data != null) { 45 | return Left(ex.response!.data.toString()); 46 | } else { 47 | return Left(ex.response!.statusMessage ?? '인증 요청 - 서버 응답 오류 01'); 48 | } 49 | } else { 50 | return Left(ex.message ?? '인증 요청 - 서버 응답 오류 02'); 51 | } 52 | } catch (ex) { 53 | return Left(ex.toString()); 54 | } 55 | } 56 | 57 | @override 58 | Future> logout() async { 59 | try { 60 | await _remote.logout(); 61 | return const Right('sucess'); 62 | } on DioException catch (ex) { 63 | if (ex.response != null) { 64 | if (ex.response!.data != null) { 65 | return Left(ex.response!.data.toString()); 66 | } else { 67 | return Left(ex.response!.statusMessage ?? '인증 요청 - 서버 응답 오류 01'); 68 | } 69 | } else { 70 | return Left(ex.message ?? '인증 요청 - 서버 응답 오류 02'); 71 | } 72 | } catch (ex) { 73 | return Left(ex.toString()); 74 | } 75 | } 76 | 77 | @override 78 | Future> register( 79 | RegisterRequest registerRequest) { 80 | // TODO: implement register 81 | throw UnimplementedError(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /lib/Data/repository/member_repository_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/data_source/remote_data_source.dart'; 2 | import 'package:basic_architecture/Data/responses/member_response.dart'; 3 | import 'package:basic_architecture/Data/responses/subscription_key_response.dart'; 4 | import 'package:basic_architecture/Domain/models/member_info.dart'; 5 | import 'package:basic_architecture/Domain/models/subscription_key.dart'; 6 | import 'package:basic_architecture/Domain/repository/member_repository.dart'; 7 | import 'package:basic_architecture/Data/translator/translator.dart'; 8 | import 'package:dartz/dartz.dart'; 9 | import 'package:dio/dio.dart'; 10 | import 'package:injectable/injectable.dart'; 11 | 12 | @LazySingleton(as: MemberRepository) 13 | class MemberRepositoryImp implements MemberRepository { 14 | final RemoteDataSource _remote; 15 | 16 | MemberRepositoryImp(this._remote); 17 | 18 | @override 19 | Future> getMemberInfo() async { 20 | try { 21 | final MemberResponse response = await _remote.getMemberInfo(); 22 | // if (response.status == 200) { 23 | // return Right(response.toDomain()); 24 | // } else { 25 | // return Left(response.message ?? '인증 요청 - 서버 응답 오류 01'); 26 | // } 27 | 28 | return Right(response.toDomain()); 29 | } on DioException catch (ex) { 30 | if (ex.response != null) { 31 | if (ex.response!.data != null) { 32 | return Left(ex.response!.data.toString()); 33 | } else { 34 | return Left(ex.response!.statusMessage ?? '사용자 정보 요청 - 서버 응답 오류 01'); 35 | } 36 | } else { 37 | return Left(ex.message ?? '사용자 정보 요청 - 서버 응답 오류 02'); 38 | } 39 | } catch (ex) { 40 | return Left(ex.toString()); 41 | } 42 | } 43 | 44 | @override 45 | Future> getSubscriptionKeyInfo() async { 46 | try { 47 | final SubscriptionKeyResponse? response = 48 | await _remote.getSubscriptionKeyResponse(); 49 | 50 | return Right(response.toDomain()); 51 | } on DioException catch (ex) { 52 | if (ex.response != null) { 53 | if (ex.response!.data != null) { 54 | return Left(ex.response!.data.toString()); 55 | } else { 56 | return Left(ex.response!.statusMessage ?? '구독 키 정보 요청 - 서버 응답 오류 01'); 57 | } 58 | } else { 59 | return Left(ex.message ?? '구독 키 정보 요청 - 서버 응답 오류 02'); 60 | } 61 | } catch (ex) { 62 | return Left(ex.toString()); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/Data/repository/sample_data_repository_imp.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/data_source/remote_data_source.dart'; 2 | import 'package:basic_architecture/Data/responses/sample_data_response.dart'; 3 | import 'package:basic_architecture/Domain/models/sample_data.dart'; 4 | import 'package:basic_architecture/Data/translator/translator.dart'; 5 | import 'package:basic_architecture/Domain/repository/sample_data_repository.dart'; 6 | import 'package:dartz/dartz.dart'; 7 | import 'package:dio/dio.dart'; 8 | import 'package:injectable/injectable.dart'; 9 | 10 | @LazySingleton(as: SampleDataRepository) 11 | class SampleDataRepositoryImp implements SampleDataRepository { 12 | final RemoteDataSource _remote; 13 | 14 | SampleDataRepositoryImp(this._remote); 15 | 16 | @override 17 | Future>> getSampleData() async { 18 | try { 19 | final List response = await _remote.getSampleData(); 20 | 21 | return Right(response.toDomainList()); 22 | } on DioException catch (ex) { 23 | if (ex.response != null) { 24 | if (ex.response!.data != null) { 25 | return Left(ex.response!.data.toString()); 26 | } else { 27 | return Left(ex.response!.statusMessage ?? '샘플 데이터 요청 - 서버 응답 오류 01'); 28 | } 29 | } else { 30 | return Left(ex.message ?? '샘플 데이터 요청 - 서버 응답 오류 02'); 31 | } 32 | } catch (ex) { 33 | return Left(ex.toString()); 34 | } 35 | } 36 | 37 | @override 38 | Future> getDetailSampleData(int id) async { 39 | try { 40 | final SampleDataResponse response = await _remote.getDetailSampleData(id); 41 | 42 | return Right(response.toDomain()); 43 | } on DioException catch (ex) { 44 | if (ex.response != null) { 45 | if (ex.response!.data != null) { 46 | return Left(ex.response!.data.toString()); 47 | } else { 48 | return Left( 49 | ex.response!.statusMessage ?? '상세 샘플 데이터 요청 - 서버 응답 오류 01'); 50 | } 51 | } else { 52 | return Left(ex.message ?? '상세 샘플 데이터 요청 - 서버 응답 오류 02'); 53 | } 54 | } catch (ex) { 55 | return Left(ex.toString()); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/Data/responses/authentication_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/responses/base_response.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'authentication_response.g.dart'; 5 | 6 | /// 로그인 요청 응답 7 | @JsonSerializable() 8 | class AuthenticationResponse extends BaseResponse { 9 | @JsonKey(name: "token") 10 | String token; 11 | @JsonKey(name: "expiration") 12 | DateTime expiration; 13 | 14 | AuthenticationResponse(this.token, this.expiration); 15 | factory AuthenticationResponse.fromJson(Map json) => 16 | _$AuthenticationResponseFromJson(json); 17 | Map toMap(Map json) => 18 | _$AuthenticationResponseToJson(this); 19 | } 20 | -------------------------------------------------------------------------------- /lib/Data/responses/authentication_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'authentication_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | AuthenticationResponse _$AuthenticationResponseFromJson( 10 | Map json) => 11 | AuthenticationResponse( 12 | json['token'] as String, 13 | DateTime.parse(json['expiration'] as String), 14 | ) 15 | ..status = json['status'] as int? 16 | ..message = json['message'] as String?; 17 | 18 | Map _$AuthenticationResponseToJson( 19 | AuthenticationResponse instance) => 20 | { 21 | 'status': instance.status, 22 | 'message': instance.message, 23 | 'token': instance.token, 24 | 'expiration': instance.expiration.toIso8601String(), 25 | }; 26 | -------------------------------------------------------------------------------- /lib/Data/responses/base_response.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ffi'; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | @JsonSerializable() 6 | class BaseResponse { 7 | @JsonKey(name: "status") 8 | int? status; 9 | 10 | @JsonKey(name: "message") 11 | String? message; 12 | } 13 | -------------------------------------------------------------------------------- /lib/Data/responses/member_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/responses/base_response.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'member_response.g.dart'; 5 | 6 | /// 유저 정보 요청 응답 7 | @JsonSerializable() 8 | class MemberResponse extends BaseResponse { 9 | @JsonKey(name: "no") 10 | int no; 11 | @JsonKey(name: "id") 12 | String id; 13 | @JsonKey(name: "role") 14 | int role; 15 | @JsonKey(name: "name") 16 | String name; 17 | @JsonKey(name: "email") 18 | String email; 19 | @JsonKey(name: "tel") 20 | String tel; 21 | @JsonKey(name: "subscriptionKeyNo") 22 | int? subscriptionKeyNo; 23 | 24 | MemberResponse(this.no, this.id, this.role, this.name, this.email, this.tel, 25 | this.subscriptionKeyNo); 26 | factory MemberResponse.fromJson(Map json) => 27 | _$MemberResponseFromJson(json); 28 | Map toMap(Map json) => 29 | _$MemberResponseToJson(this); 30 | } 31 | -------------------------------------------------------------------------------- /lib/Data/responses/member_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'member_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | MemberResponse _$MemberResponseFromJson(Map json) => 10 | MemberResponse( 11 | json['no'] as int, 12 | json['id'] as String, 13 | json['role'] as int, 14 | json['name'] as String, 15 | json['email'] as String, 16 | json['tel'] as String, 17 | json['subscriptionKeyNo'] as int?, 18 | ) 19 | ..status = json['status'] as int? 20 | ..message = json['message'] as String?; 21 | 22 | Map _$MemberResponseToJson(MemberResponse instance) => 23 | { 24 | 'status': instance.status, 25 | 'message': instance.message, 26 | 'no': instance.no, 27 | 'id': instance.id, 28 | 'role': instance.role, 29 | 'name': instance.name, 30 | 'email': instance.email, 31 | 'tel': instance.tel, 32 | 'subscriptionKeyNo': instance.subscriptionKeyNo, 33 | }; 34 | -------------------------------------------------------------------------------- /lib/Data/responses/sample_data_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/responses/base_response.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'sample_data_response.g.dart'; 5 | 6 | /// 유저 정보 요청 응답 7 | @JsonSerializable() 8 | class SampleDataResponse extends BaseResponse { 9 | @JsonKey(name: "userId") 10 | int userId; 11 | @JsonKey(name: "id") 12 | int id; 13 | @JsonKey(name: "title") 14 | String title; 15 | @JsonKey(name: "body") 16 | String body; 17 | 18 | SampleDataResponse(this.userId, this.id, this.title, this.body); 19 | factory SampleDataResponse.fromJson(Map json) => 20 | _$SampleDataResponseFromJson(json); 21 | Map toMap(Map json) => 22 | _$SampleDataResponseToJson(this); 23 | } 24 | -------------------------------------------------------------------------------- /lib/Data/responses/sample_data_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'sample_data_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | SampleDataResponse _$SampleDataResponseFromJson(Map json) => 10 | SampleDataResponse( 11 | json['userId'] as int, 12 | json['id'] as int, 13 | json['title'] as String, 14 | json['body'] as String, 15 | ) 16 | ..status = json['status'] as int? 17 | ..message = json['message'] as String?; 18 | 19 | Map _$SampleDataResponseToJson(SampleDataResponse instance) => 20 | { 21 | 'status': instance.status, 22 | 'message': instance.message, 23 | 'userId': instance.userId, 24 | 'id': instance.id, 25 | 'title': instance.title, 26 | 'body': instance.body, 27 | }; 28 | -------------------------------------------------------------------------------- /lib/Data/responses/subscription_key_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/responses/base_response.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'subscription_key_response.g.dart'; 5 | 6 | /// 구독 키 정보 요청 응답 7 | @JsonSerializable() 8 | class SubscriptionKeyResponse extends BaseResponse { 9 | @JsonKey(name: "key") 10 | String key; 11 | @JsonKey(name: "keyType") 12 | String keyType; 13 | @JsonKey(name: "startDT") 14 | DateTime startDT; 15 | @JsonKey(name: "endDT") 16 | DateTime endDT; 17 | @JsonKey(name: "createDT") 18 | DateTime createDT; 19 | @JsonKey(name: "memo") 20 | String memo; 21 | 22 | SubscriptionKeyResponse(this.key, this.keyType, this.startDT, this.endDT, 23 | this.createDT, this.memo); 24 | factory SubscriptionKeyResponse.fromJson(Map json) => 25 | _$SubscriptionKeyResponseFromJson(json); 26 | Map toMap(Map json) => 27 | _$SubscriptionKeyResponseToJson(this); 28 | } 29 | -------------------------------------------------------------------------------- /lib/Data/responses/subscription_key_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'subscription_key_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | SubscriptionKeyResponse _$SubscriptionKeyResponseFromJson( 10 | Map json) => 11 | SubscriptionKeyResponse( 12 | json['key'] as String, 13 | json['keyType'] as String, 14 | DateTime.parse(json['startDT'] as String), 15 | DateTime.parse(json['endDT'] as String), 16 | DateTime.parse(json['createDT'] as String), 17 | json['memo'] as String, 18 | ) 19 | ..status = json['status'] as int? 20 | ..message = json['message'] as String?; 21 | 22 | Map _$SubscriptionKeyResponseToJson( 23 | SubscriptionKeyResponse instance) => 24 | { 25 | 'status': instance.status, 26 | 'message': instance.message, 27 | 'key': instance.key, 28 | 'keyType': instance.keyType, 29 | 'startDT': instance.startDT.toIso8601String(), 30 | 'endDT': instance.endDT.toIso8601String(), 31 | 'createDT': instance.createDT.toIso8601String(), 32 | 'memo': instance.memo, 33 | }; 34 | -------------------------------------------------------------------------------- /lib/Data/translator/translator.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Data/responses/authentication_response.dart'; 2 | import 'package:basic_architecture/Data/responses/member_response.dart'; 3 | import 'package:basic_architecture/Data/responses/sample_data_response.dart'; 4 | import 'package:basic_architecture/Data/responses/subscription_key_response.dart'; 5 | import 'package:basic_architecture/Domain/models/authentication.dart'; 6 | import 'package:basic_architecture/Domain/models/member_info.dart'; 7 | import 'package:basic_architecture/Domain/models/sample_data.dart'; 8 | import 'package:basic_architecture/Domain/models/subscription_key.dart'; 9 | 10 | /// Data entity -> Domain model 변환 11 | extension AuthenticationResponseTranslator on AuthenticationResponse? { 12 | Authentication toDomain() { 13 | return Authentication(this!.token, this!.expiration); 14 | } 15 | } 16 | 17 | extension MemberResponseTranslator on MemberResponse? { 18 | MemberInfo toDomain() { 19 | return MemberInfo(this!.no, this!.id, this!.role, this!.name, this?.email, 20 | this?.tel, this?.subscriptionKeyNo); 21 | } 22 | } 23 | 24 | extension SampleDataResponseTranslator on SampleDataResponse? { 25 | SampleData toDomain() { 26 | return SampleData(this!.userId, this!.id, this!.title, this!.body); 27 | } 28 | } 29 | 30 | extension SampleDataResponseListTranslator on List? { 31 | List toDomainList() { 32 | return this?.map((response) => response.toDomain())?.toList() ?? []; 33 | } 34 | } 35 | 36 | extension SubscriptionKeyResponseTranslator on SubscriptionKeyResponse? { 37 | SubscriptionKey? toDomain() { 38 | if (this == null) return null; 39 | 40 | return SubscriptionKey(this!.key, this!.keyType, this!.startDT, this!.endDT, 41 | this!.createDT, this!.memo); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/Domain/models/authentication.dart: -------------------------------------------------------------------------------- 1 | class Authentication { 2 | final String token; 3 | final DateTime expiration; 4 | 5 | const Authentication(this.token, this.expiration); 6 | } 7 | -------------------------------------------------------------------------------- /lib/Domain/models/member_info.dart: -------------------------------------------------------------------------------- 1 | class MemberInfo { 2 | final int no; 3 | final String id; 4 | final int role; 5 | final String name; 6 | final String? email; 7 | final String? tel; 8 | final int? subscriptionKey; 9 | 10 | const MemberInfo( 11 | this.no, this.id, this.role, this.name, this.email, this.tel, this.subscriptionKey); 12 | } 13 | -------------------------------------------------------------------------------- /lib/Domain/models/sample_data.dart: -------------------------------------------------------------------------------- 1 | class SampleData { 2 | final int userID; 3 | final int id; 4 | final String title; 5 | final String body; 6 | 7 | const SampleData(this.userID, this.id, this.title, this.body); 8 | } 9 | -------------------------------------------------------------------------------- /lib/Domain/models/subscription_key.dart: -------------------------------------------------------------------------------- 1 | class SubscriptionKey { 2 | final String key; 3 | final String keyType; 4 | final DateTime startDT; 5 | final DateTime endDT; 6 | final DateTime createDT; 7 | final String memo; 8 | 9 | const SubscriptionKey(this.key, this.keyType, this.startDT, this.endDT, this.createDT, this.memo); 10 | } 11 | -------------------------------------------------------------------------------- /lib/Domain/repository/authentication_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/authentication.dart'; 2 | import 'package:basic_architecture/Domain/request/login_request.dart'; 3 | import 'package:basic_architecture/Domain/request/register_request.dart'; 4 | import 'package:dartz/dartz.dart'; 5 | 6 | abstract class AuthenticationRepository{ 7 | Future> login(LoginRequest loginRequest); 8 | Future> logout(); 9 | Future> forgotPassword(String id); 10 | Future> register(RegisterRequest registerRequest); 11 | } -------------------------------------------------------------------------------- /lib/Domain/repository/member_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/member_info.dart'; 2 | import 'package:basic_architecture/Domain/models/subscription_key.dart'; 3 | import 'package:dartz/dartz.dart'; 4 | 5 | abstract class MemberRepository { 6 | Future> getMemberInfo(); 7 | Future> getSubscriptionKeyInfo(); 8 | } 9 | -------------------------------------------------------------------------------- /lib/Domain/repository/sample_data_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/sample_data.dart'; 2 | import 'package:dartz/dartz.dart'; 3 | 4 | abstract class SampleDataRepository { 5 | Future>> getSampleData(); 6 | Future> getDetailSampleData(int id); 7 | } 8 | -------------------------------------------------------------------------------- /lib/Domain/request/login_request.dart: -------------------------------------------------------------------------------- 1 | class LoginRequest { 2 | String id; 3 | String password; 4 | 5 | LoginRequest(this.id, this.password); 6 | } 7 | -------------------------------------------------------------------------------- /lib/Domain/request/register_request.dart: -------------------------------------------------------------------------------- 1 | class RegisterRequest { 2 | String id; 3 | String password; 4 | int role; 5 | String name; 6 | String? email; 7 | String? tel; 8 | 9 | RegisterRequest(this.id, this.password, this.role, this.name, {this.email, this.tel}); 10 | } 11 | -------------------------------------------------------------------------------- /lib/Domain/usecase/base_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | 3 | /// Base UseCase 4 | /// clean-architecture의 UseCase 규칙 : 한 개의 행동을 담당, Input과 Output의 단일 실행 메서드만 외부에 제공한다. 5 | abstract class BaseUseCase { 6 | Future> execute(In input); 7 | } 8 | -------------------------------------------------------------------------------- /lib/Domain/usecase/detail_load_sample_data_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/sample_data.dart'; 2 | import 'package:basic_architecture/Domain/repository/sample_data_repository.dart'; 3 | import 'package:basic_architecture/Domain/usecase/base_usecase.dart'; 4 | import 'package:dartz/dartz.dart'; 5 | import 'package:injectable/injectable.dart'; 6 | 7 | @injectable 8 | class DetailLoadSampleDataUseCase implements BaseUseCase { 9 | final SampleDataRepository _sampleDataRepository; 10 | 11 | DetailLoadSampleDataUseCase(this._sampleDataRepository); 12 | 13 | @override 14 | Future> execute(int input) async { 15 | return await _sampleDataRepository.getDetailSampleData(input); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/Domain/usecase/load_sample_data_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/sample_data.dart'; 2 | import 'package:basic_architecture/Domain/repository/sample_data_repository.dart'; 3 | import 'package:basic_architecture/Domain/usecase/base_usecase.dart'; 4 | import 'package:dartz/dartz.dart'; 5 | import 'package:injectable/injectable.dart'; 6 | 7 | @injectable 8 | class LoadSampleDataUseCase implements BaseUseCase> { 9 | final SampleDataRepository _sampleDataRepository; 10 | 11 | LoadSampleDataUseCase(this._sampleDataRepository); 12 | 13 | @override 14 | Future>> execute(void input) async { 15 | return await _sampleDataRepository.getSampleData(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/Domain/usecase/login_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/authentication.dart'; 2 | import 'package:basic_architecture/Domain/repository/authentication_repository.dart'; 3 | import 'package:basic_architecture/Domain/request/login_request.dart'; 4 | import 'package:basic_architecture/Domain/usecase/base_usecase.dart'; 5 | import 'package:dartz/dartz.dart'; 6 | import 'package:injectable/injectable.dart'; 7 | 8 | @injectable 9 | class LoginUseCase implements BaseUseCase { 10 | final AuthenticationRepository _authenticationRepository; 11 | 12 | LoginUseCase(this._authenticationRepository); 13 | 14 | @override 15 | Future> execute( 16 | LoginUseCaseInput input) async { 17 | return await _authenticationRepository 18 | .login(LoginRequest(input.id, input.password)); 19 | } 20 | } 21 | 22 | class LoginUseCaseInput { 23 | String id; 24 | String password; 25 | LoginUseCaseInput(this.id, this.password); 26 | } 27 | -------------------------------------------------------------------------------- /lib/Domain/usecase/logout_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/authentication.dart'; 2 | import 'package:basic_architecture/Domain/repository/authentication_repository.dart'; 3 | import 'package:basic_architecture/Domain/request/login_request.dart'; 4 | import 'package:basic_architecture/Domain/usecase/base_usecase.dart'; 5 | import 'package:dartz/dartz.dart'; 6 | import 'package:injectable/injectable.dart'; 7 | 8 | @injectable 9 | class LogoutUseCase implements BaseUseCase { 10 | final AuthenticationRepository _authenticationRepository; 11 | 12 | LogoutUseCase(this._authenticationRepository); 13 | 14 | @override 15 | Future> execute(void input) async { 16 | return await _authenticationRepository.logout(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/Domain/usecase/member_info_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/member_info.dart'; 2 | import 'package:basic_architecture/Domain/repository/member_repository.dart'; 3 | import 'package:basic_architecture/Domain/usecase/base_usecase.dart'; 4 | import 'package:dartz/dartz.dart'; 5 | import 'package:injectable/injectable.dart'; 6 | 7 | @injectable 8 | class MemberInfoUseCase implements BaseUseCase { 9 | final MemberRepository _memberRepository; 10 | 11 | MemberInfoUseCase(this._memberRepository); 12 | 13 | @override 14 | Future> execute(void input) async { 15 | return await _memberRepository 16 | .getMemberInfo(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/Domain/usecase/subscription_key_info_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Domain/models/subscription_key.dart'; 2 | import 'package:basic_architecture/Domain/repository/member_repository.dart'; 3 | import 'package:basic_architecture/Domain/usecase/base_usecase.dart'; 4 | import 'package:dartz/dartz.dart'; 5 | import 'package:injectable/injectable.dart'; 6 | 7 | @injectable 8 | class SubscriptionKeyInfoUseCase implements BaseUseCase { 9 | final MemberRepository _memberRepository; 10 | 11 | SubscriptionKeyInfoUseCase(this._memberRepository); 12 | 13 | @override 14 | Future> execute(void input) async { 15 | return await _memberRepository.getSubscriptionKeyInfo(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/Injectable/configurations.config.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | // ************************************************************************** 4 | // InjectableConfigGenerator 5 | // ************************************************************************** 6 | 7 | // ignore_for_file: type=lint 8 | // coverage:ignore-file 9 | 10 | // ignore_for_file: no_leading_underscores_for_library_prefixes 11 | import 'package:get_it/get_it.dart' as _i1; 12 | import 'package:injectable/injectable.dart' as _i2; 13 | 14 | import '../App/app_preferences.dart' as _i16; 15 | import '../Data/data_source/remote_data_source.dart' as _i5; 16 | import '../Data/repository/authentication_repository_imp.dart' as _i4; 17 | import '../Data/repository/member_repository_imp.dart' as _i9; 18 | import '../Data/repository/sample_data_repository_imp.dart' as _i11; 19 | import '../Domain/repository/authentication_repository.dart' as _i3; 20 | import '../Domain/repository/member_repository.dart' as _i8; 21 | import '../Domain/repository/sample_data_repository.dart' as _i10; 22 | import '../Domain/usecase/detail_load_sample_data_usecase.dart' as _i13; 23 | import '../Domain/usecase/load_sample_data_usecase.dart' as _i14; 24 | import '../Domain/usecase/login_usecase.dart' as _i6; 25 | import '../Domain/usecase/logout_usecase.dart' as _i7; 26 | import '../Domain/usecase/member_info_usecase.dart' as _i17; 27 | import '../Domain/usecase/subscription_key_info_usecase.dart' as _i12; 28 | import '../Presentation/authentication/bloc/authentication_bloc.dart' as _i20; 29 | import '../Presentation/home/bloc/sample_data_bloc.dart' as _i18; 30 | import '../Presentation/login/bloc/login_bloc.dart' as _i15; 31 | import '../Presentation/subscription_info/bloc/subscription_info_bloc.dart' 32 | as _i19; 33 | 34 | // initializes the registration of main-scope dependencies inside of GetIt 35 | _i1.GetIt $initGetIt( 36 | _i1.GetIt getIt, { 37 | String? environment, 38 | _i2.EnvironmentFilter? environmentFilter, 39 | }) { 40 | final gh = _i2.GetItHelper( 41 | getIt, 42 | environment, 43 | environmentFilter, 44 | ); 45 | gh.lazySingleton<_i3.AuthenticationRepository>( 46 | () => _i4.AuthenticationRepositoryImp(gh<_i5.RemoteDataSource>())); 47 | gh.factory<_i6.LoginUseCase>( 48 | () => _i6.LoginUseCase(gh<_i3.AuthenticationRepository>())); 49 | gh.factory<_i7.LogoutUseCase>( 50 | () => _i7.LogoutUseCase(gh<_i3.AuthenticationRepository>())); 51 | gh.lazySingleton<_i8.MemberRepository>( 52 | () => _i9.MemberRepositoryImp(gh<_i5.RemoteDataSource>())); 53 | gh.lazySingleton<_i10.SampleDataRepository>( 54 | () => _i11.SampleDataRepositoryImp(gh<_i5.RemoteDataSource>())); 55 | gh.factory<_i12.SubscriptionKeyInfoUseCase>( 56 | () => _i12.SubscriptionKeyInfoUseCase(gh<_i8.MemberRepository>())); 57 | gh.factory<_i13.DetailLoadSampleDataUseCase>( 58 | () => _i13.DetailLoadSampleDataUseCase(gh<_i10.SampleDataRepository>())); 59 | gh.factory<_i14.LoadSampleDataUseCase>( 60 | () => _i14.LoadSampleDataUseCase(gh<_i10.SampleDataRepository>())); 61 | gh.factory<_i15.LoginBloc>(() => _i15.LoginBloc( 62 | gh<_i16.AppPreferences>(), 63 | gh<_i6.LoginUseCase>(), 64 | )); 65 | gh.factory<_i17.MemberInfoUseCase>( 66 | () => _i17.MemberInfoUseCase(gh<_i8.MemberRepository>())); 67 | gh.factory<_i18.SampleDataBloc>(() => _i18.SampleDataBloc( 68 | gh<_i16.AppPreferences>(), 69 | gh<_i14.LoadSampleDataUseCase>(), 70 | gh<_i13.DetailLoadSampleDataUseCase>(), 71 | )); 72 | gh.factory<_i19.SubscriptionInfoBloc>(() => _i19.SubscriptionInfoBloc( 73 | gh<_i16.AppPreferences>(), 74 | gh<_i12.SubscriptionKeyInfoUseCase>(), 75 | )); 76 | gh.factory<_i20.AuthenticationBloc>(() => _i20.AuthenticationBloc( 77 | gh<_i16.AppPreferences>(), 78 | gh<_i7.LogoutUseCase>(), 79 | gh<_i17.MemberInfoUseCase>(), 80 | )); 81 | return getIt; 82 | } 83 | -------------------------------------------------------------------------------- /lib/Injectable/configurations.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app_preferences.dart'; 2 | import 'package:basic_architecture/Data/data_source/remote_data_source.dart'; 3 | import 'package:basic_architecture/Data/data_source/remote_data_source_imp.dart'; 4 | import 'package:basic_architecture/Data/network/api_client.dart'; 5 | import 'package:basic_architecture/Data/network/api_provider.dart'; 6 | import 'package:basic_architecture/Data/network/api_sample_data_service.dart'; 7 | import 'package:basic_architecture/Data/network/api_service.dart'; 8 | import 'package:dio/dio.dart'; 9 | import 'package:get_it/get_it.dart'; 10 | import 'package:injectable/injectable.dart'; 11 | import 'package:shared_preferences/shared_preferences.dart'; 12 | 13 | import 'configurations.config.dart' as config; 14 | 15 | final getIt = GetIt.instance; 16 | 17 | @InjectableInit( 18 | initializerName: r'$initGetIt', 19 | preferRelativeImports: true, 20 | asExtension: false, 21 | ) 22 | Future configureDependencies() => $initGetIt(getIt); 23 | 24 | Future $initGetIt( 25 | GetIt getIt, { 26 | String? environment, 27 | EnvironmentFilter? environmentFilter, 28 | }) async { 29 | final gh = GetItHelper(getIt, environment.toString()); 30 | final sharedPreferences = await SharedPreferences.getInstance(); 31 | 32 | // IoC 등록 33 | gh.lazySingleton(() => AppPreferences(sharedPreferences)); 34 | 35 | // Http 요청 처리 등록 36 | var baseApiClient = ApiClient(ApiType.base, enableLogging: true); 37 | 38 | // Dio 등록 [ApiClient에서 생성한 apiProvider가 가지고 있는 Dio] 39 | gh.factory(() => baseApiClient.apiProvider.getDio); 40 | 41 | // 실제 RestFul API 처리 서비스 등록 42 | gh.factory(() => ApiService(getIt())); 43 | 44 | // 샘플 RestFul API 처리 서비스 등록 45 | var sampleDataApiClient = ApiClient(ApiType.sampleData, enableLogging: true); 46 | gh.factory( 47 | () => ApiSampleDataService(sampleDataApiClient.apiProvider.getDio)); 48 | 49 | // RestFul API 서비스를 사용하는 원격 데이터 소스 50 | gh.factory(() => 51 | RemoteDataSourceImp(getIt(), getIt())); 52 | 53 | config.$initGetIt(getIt); 54 | } 55 | -------------------------------------------------------------------------------- /lib/Presentation/authentication/bloc/authentication_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app_preferences.dart'; 2 | import 'package:basic_architecture/Domain/usecase/login_usecase.dart'; 3 | import 'package:basic_architecture/Domain/usecase/logout_usecase.dart'; 4 | import 'package:basic_architecture/Domain/usecase/member_info_usecase.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:equatable/equatable.dart'; 8 | import 'package:injectable/injectable.dart'; 9 | 10 | import 'member_viewmodel.dart'; 11 | 12 | part 'authentication_event.dart'; 13 | part 'authentication_state.dart'; 14 | 15 | @injectable 16 | class AuthenticationBloc 17 | extends Bloc { 18 | final AppPreferences _appPreferences; 19 | final LogoutUseCase _logoutUseCase; 20 | final MemberInfoUseCase _memberInfoUseCase; 21 | 22 | AuthenticationBloc( 23 | this._appPreferences, this._logoutUseCase, this._memberInfoUseCase) 24 | : super(const AuthenticationUninitialized()) { 25 | on( 26 | (e, __) => onAuthenticationStatusChanged(e.status)); 27 | on( 28 | (_, __) => onAuthenticationLogoutRequested()); 29 | } 30 | 31 | Future onAuthenticationStatusChanged( 32 | AuthenticationStatus status) async { 33 | // test! 34 | //////////////await _appPreferences.logout(); 35 | switch (status) { 36 | case AuthenticationStatus.loading: 37 | // 로그인 되어 있는 상태라면, 38 | // secure storage에 보관되어 있는 AccessToken으로 사용자 정보를 가져온다. 39 | // 사용자 정보 요청 성공인 경우 Main home page로 이동 40 | // 로그인 되어 있지 않은 상태거나, AccessToken 토큰이 유효하지 않아 사용자 정보 요청 실패인 경우 Login page로 이동 41 | var isUserLoggedIn = _appPreferences.userToken; 42 | if (isUserLoggedIn == null || isUserLoggedIn == false) { 43 | emit(const AuthenticationUninitialized()); 44 | } else { 45 | onAuthenticationStatusChanged(AuthenticationStatus.authenticated); 46 | } 47 | break; 48 | 49 | case AuthenticationStatus.uninitialized: 50 | emit(const AuthenticationUninitialized()); 51 | break; 52 | 53 | case AuthenticationStatus.authenticated: 54 | final memberResult = await _memberInfoUseCase.execute(null); 55 | memberResult.fold( 56 | (left) => emit(const AuthenticationUnauthenticated()), 57 | (right) => { 58 | if (right != null) 59 | { 60 | emit(AuthenticationAuthenticated(MemberViewModel( 61 | no: right.no, 62 | id: right.id, 63 | name: right.name, 64 | email: right.email, 65 | tel: right.tel, 66 | subscriptionKey: right.subscriptionKey))) 67 | } 68 | else 69 | {emit(const AuthenticationUnauthenticated())} 70 | }); 71 | 72 | break; 73 | 74 | case AuthenticationStatus.unauthenticated: 75 | emit(const AuthenticationUnauthenticated()); 76 | break; 77 | 78 | default: 79 | emit(const AuthenticationUninitialized()); 80 | break; 81 | } 82 | } 83 | 84 | Future onAuthenticationLogoutRequested() async { 85 | await _appPreferences.logout(); 86 | final result = await _logoutUseCase.execute(null); 87 | result.fold((l) => null, (r) => emit(const AuthenticationUninitialized())); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /lib/Presentation/authentication/bloc/authentication_event.dart: -------------------------------------------------------------------------------- 1 | part of 'authentication_bloc.dart'; 2 | 3 | @immutable 4 | abstract class AuthenticationEvent extends Equatable { 5 | @override 6 | List get props => []; 7 | } 8 | 9 | final class AuthenticationStatusChanged extends AuthenticationEvent { 10 | final AuthenticationStatus status; 11 | 12 | AuthenticationStatusChanged(this.status); 13 | } 14 | 15 | final class AuthenticationLogoutRequested extends AuthenticationEvent {} -------------------------------------------------------------------------------- /lib/Presentation/authentication/bloc/authentication_state.dart: -------------------------------------------------------------------------------- 1 | part of 'authentication_bloc.dart'; 2 | 3 | enum AuthenticationStatus { 4 | // 초기화 되지 않음 5 | uninitialized, 6 | // 로딩중 7 | loading, 8 | // 인증 완료 9 | authenticated, 10 | // 인증 실패 11 | unauthenticated 12 | } 13 | 14 | abstract class AuthenticationState extends Equatable { 15 | final AuthenticationStatus status; 16 | final MemberViewModel? userViewModel; 17 | 18 | const AuthenticationState(this.status, this.userViewModel); 19 | 20 | @override 21 | List get props => [status, userViewModel]; 22 | } 23 | 24 | /// 초기화 되지 않음 25 | class AuthenticationUninitialized extends AuthenticationState { 26 | const AuthenticationUninitialized(): super(AuthenticationStatus.uninitialized, null); 27 | 28 | @override 29 | String toString() => 'AuthenticationUninitialized'; 30 | } 31 | 32 | /// 인증 성공 33 | class AuthenticationAuthenticated extends AuthenticationState { 34 | const AuthenticationAuthenticated(MemberViewModel userViewModel): super(AuthenticationStatus.authenticated, userViewModel); 35 | 36 | @override 37 | String toString() => 'AuthenticationAuthenticated'; 38 | } 39 | 40 | /// 인증 실패 41 | class AuthenticationUnauthenticated extends AuthenticationState { 42 | const AuthenticationUnauthenticated(): super(AuthenticationStatus.unauthenticated, null); 43 | 44 | @override 45 | String toString() => 'AuthenticationUnauthenticated'; 46 | } 47 | 48 | /// 인증 처리중 [로딩] 49 | class AuthenticationLoading extends AuthenticationState { 50 | const AuthenticationLoading(): super(AuthenticationStatus.loading, null); 51 | 52 | @override 53 | String toString() => 'AuthenticationLoading'; 54 | } 55 | -------------------------------------------------------------------------------- /lib/Presentation/authentication/bloc/member_viewmodel.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | /// Presentation의 View에서 Domain 계층의 model 정보를 모두 사용하지 않기 위해 4 | /// 별도의 ViewModel을 정의하여 해당 View에서만 사용. 5 | 6 | /// To avoid using all model information of the domain layer in the presentation view 7 | /// Define a separate ViewModel and use it only in that View. 8 | class MemberViewModel extends Equatable { 9 | final int no; 10 | final String id; 11 | final String? name; 12 | final String? email; 13 | final String? tel; 14 | final int? subscriptionKey; 15 | 16 | const MemberViewModel( 17 | {required this.no, 18 | required this.id, 19 | required this.name, 20 | required this.email, 21 | required this.tel, 22 | this.subscriptionKey}); 23 | 24 | @override 25 | List get props => [no, id, name, email, tel, subscriptionKey]; 26 | } 27 | -------------------------------------------------------------------------------- /lib/Presentation/component/placeholders.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class BannerPlaceholder extends StatelessWidget { 4 | const BannerPlaceholder({Key? key}) : super(key: key); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Container( 9 | width: double.infinity, 10 | height: 200.0, 11 | margin: const EdgeInsets.all(16.0), 12 | decoration: BoxDecoration( 13 | borderRadius: BorderRadius.circular(12.0), 14 | color: Colors.white, 15 | ), 16 | ); 17 | } 18 | } 19 | 20 | class TitlePlaceholder extends StatelessWidget { 21 | final double width; 22 | 23 | const TitlePlaceholder({ 24 | Key? key, 25 | required this.width, 26 | }) : super(key: key); 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | return Padding( 31 | padding: const EdgeInsets.symmetric(horizontal: 16.0), 32 | child: Column( 33 | mainAxisSize: MainAxisSize.min, 34 | crossAxisAlignment: CrossAxisAlignment.start, 35 | children: [ 36 | Container( 37 | width: width, 38 | height: 12.0, 39 | color: Colors.white, 40 | ), 41 | const SizedBox(height: 8.0), 42 | Container( 43 | width: width, 44 | height: 12.0, 45 | color: Colors.white, 46 | ), 47 | ], 48 | ), 49 | ); 50 | } 51 | } 52 | 53 | enum ContentLineType { 54 | twoLines, 55 | threeLines, 56 | } 57 | 58 | class ContentPlaceholder extends StatelessWidget { 59 | final ContentLineType lineType; 60 | 61 | const ContentPlaceholder({ 62 | Key? key, 63 | required this.lineType, 64 | }) : super(key: key); 65 | 66 | @override 67 | Widget build(BuildContext context) { 68 | return Padding( 69 | padding: const EdgeInsets.symmetric(horizontal: 16.0), 70 | child: Row( 71 | mainAxisSize: MainAxisSize.max, 72 | crossAxisAlignment: CrossAxisAlignment.center, 73 | children: [ 74 | Container( 75 | width: 96.0, 76 | height: 72.0, 77 | decoration: BoxDecoration( 78 | borderRadius: BorderRadius.circular(12.0), 79 | color: Colors.white, 80 | ), 81 | ), 82 | const SizedBox(width: 12.0), 83 | Expanded( 84 | child: Column( 85 | mainAxisSize: MainAxisSize.min, 86 | crossAxisAlignment: CrossAxisAlignment.start, 87 | children: [ 88 | Container( 89 | width: double.infinity, 90 | height: 10.0, 91 | color: Colors.white, 92 | margin: const EdgeInsets.only(bottom: 8.0), 93 | ), 94 | if (lineType == ContentLineType.threeLines) 95 | Container( 96 | width: double.infinity, 97 | height: 10.0, 98 | color: Colors.white, 99 | margin: const EdgeInsets.only(bottom: 8.0), 100 | ), 101 | Container( 102 | width: 100.0, 103 | height: 10.0, 104 | color: Colors.white, 105 | ) 106 | ], 107 | ), 108 | ) 109 | ], 110 | ), 111 | ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /lib/Presentation/home/bloc/sample_data_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app_preferences.dart'; 2 | import 'package:basic_architecture/Domain/models/sample_data.dart'; 3 | import 'package:basic_architecture/Domain/usecase/detail_load_sample_data_usecase.dart'; 4 | import 'package:basic_architecture/Domain/usecase/load_sample_data_usecase.dart'; 5 | import 'package:equatable/equatable.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter_bloc/flutter_bloc.dart'; 8 | import 'package:injectable/injectable.dart'; 9 | 10 | part 'sample_data_event.dart'; 11 | part 'sample_data_state.dart'; 12 | 13 | @injectable 14 | class SampleDataBloc extends Bloc { 15 | final AppPreferences _appPreferences; 16 | final LoadSampleDataUseCase _loadSampleDataUsecase; 17 | final DetailLoadSampleDataUseCase _detailLoadSampleDataUsecase; 18 | 19 | SampleDataBloc(this._appPreferences, this._loadSampleDataUsecase, 20 | this._detailLoadSampleDataUsecase) 21 | : super(const LoadingState()) { 22 | on(_onGetSampleDataListEvent); 23 | on( 24 | (event, emit) => _onGetDetailSampleDataEvent(event.id, emit)); 25 | } 26 | 27 | Future _onGetSampleDataListEvent( 28 | GetSampleDataListEvent event, 29 | Emitter emit, 30 | ) async { 31 | // 데이터 요청중 32 | emit(const LoadingState()); 33 | 34 | // 임의로 2초 딜레이 35 | await Future.delayed(const Duration(seconds: 2)); 36 | 37 | var sampleDataList = await _loadSampleDataUsecase.execute(null); 38 | sampleDataList.fold( 39 | (left) => emit(const ErrorState()), 40 | (right) => { 41 | if (right.isEmpty) 42 | {emit(const EmptyDataState())} 43 | else 44 | {emit(LoadedState(right))} 45 | }, 46 | ); 47 | } 48 | 49 | Future _onGetDetailSampleDataEvent( 50 | int id, Emitter emit) async { 51 | // 데이터 요청중 52 | emit(const DetailFetechingState()); 53 | 54 | // 임의로 2초 딜레이 55 | await Future.delayed(const Duration(seconds: 2)); 56 | 57 | var sampleDataList = await _detailLoadSampleDataUsecase.execute(id); 58 | sampleDataList.fold( 59 | (left) => emit(const DetailErrorState()), 60 | (right) => emit(DetailLoadedState(right)), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/Presentation/home/bloc/sample_data_event.dart: -------------------------------------------------------------------------------- 1 | part of 'sample_data_bloc.dart'; 2 | 3 | @immutable 4 | abstract class SampleDataEvent extends Equatable { 5 | @override 6 | List get props => []; 7 | } 8 | 9 | /// 데이터 로드 이벤트 10 | final class GetSampleDataListEvent extends SampleDataEvent {} 11 | 12 | /// 데이터 상세 보기 로드 이벤트 13 | final class GetDetailSampleDataEvent extends SampleDataEvent { 14 | final int id; 15 | GetDetailSampleDataEvent(this.id); 16 | 17 | @override 18 | List get props => [id]; 19 | } 20 | -------------------------------------------------------------------------------- /lib/Presentation/home/bloc/sample_data_state.dart: -------------------------------------------------------------------------------- 1 | part of 'sample_data_bloc.dart'; 2 | 3 | enum DataLoadStatus { 4 | // 데이터 없음 5 | empty, 6 | // 로딩중 7 | loading, 8 | // 상세 내용 요청중 9 | feteching, 10 | // 데이터 요청 오류 11 | error, 12 | // 상세 데이터 요청 오류 13 | detailError, 14 | // 로드 완료 15 | loaded, 16 | // 상세 데이터 로드 완료 17 | detailLoaded, 18 | } 19 | 20 | abstract class SampleDataState extends Equatable { 21 | final DataLoadStatus status; 22 | final List? sampleDataList; 23 | final SampleData? detailSampleData; 24 | 25 | const SampleDataState(this.status, 26 | {this.sampleDataList, this.detailSampleData}); 27 | 28 | @override 29 | List get props => [status, sampleDataList, detailSampleData]; 30 | } 31 | 32 | /// 데이터 없음 33 | class EmptyDataState extends SampleDataState { 34 | const EmptyDataState() : super(DataLoadStatus.empty); 35 | } 36 | 37 | /// 데이터 요청중 38 | class LoadingState extends SampleDataState { 39 | const LoadingState() : super(DataLoadStatus.loading); 40 | } 41 | 42 | /// 데이터 요청 오류 43 | class ErrorState extends SampleDataState { 44 | const ErrorState() : super(DataLoadStatus.error); 45 | } 46 | 47 | /// 로드 완료 48 | class LoadedState extends SampleDataState { 49 | final List _sampleDataList; 50 | const LoadedState(this._sampleDataList) 51 | : super(DataLoadStatus.loaded, sampleDataList: _sampleDataList); 52 | } 53 | 54 | /// 상세 내용 데이터 요청중 55 | class DetailFetechingState extends SampleDataState { 56 | const DetailFetechingState() : super(DataLoadStatus.feteching); 57 | } 58 | 59 | /// 상세 데이터 요청 오류 60 | class DetailErrorState extends SampleDataState { 61 | const DetailErrorState() : super(DataLoadStatus.detailError); 62 | } 63 | 64 | /// 상세 내용 로드 완료 65 | class DetailLoadedState extends SampleDataState { 66 | final SampleData _detailSampleData; 67 | const DetailLoadedState(this._detailSampleData) 68 | : super(DataLoadStatus.detailLoaded, detailSampleData: _detailSampleData); 69 | } 70 | -------------------------------------------------------------------------------- /lib/Presentation/home/view/app_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Injectable/configurations.dart'; 2 | import 'package:basic_architecture/Presentation/authentication/bloc/authentication_bloc.dart'; 3 | import 'package:basic_architecture/Presentation/home/bloc/sample_data_bloc.dart'; 4 | import 'package:basic_architecture/Presentation/home/view/desktop_home_view.dart'; 5 | import 'package:basic_architecture/Presentation/home/view/mobile_home_view.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter_bloc/flutter_bloc.dart'; 8 | 9 | class AppView extends StatelessWidget { 10 | final Widget mobileView = const MobileView(); 11 | final Widget desktopView = const DesktopHomeView(); 12 | static const int _maxWidth = 900; 13 | 14 | const AppView({Key? key}) : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context) => MultiBlocProvider( 18 | providers: [ 19 | BlocProvider( 20 | create: (context) => getIt() 21 | ..add( 22 | GetSampleDataListEvent(), 23 | ), 24 | ), 25 | BlocProvider( 26 | create: (context) => getIt(), 27 | ), 28 | ], 29 | child: LayoutBuilder( 30 | builder: (context, constraints) { 31 | if (constraints.maxWidth < _maxWidth) { 32 | return mobileView; 33 | } else { 34 | return desktopView; 35 | } 36 | }, 37 | ), 38 | ); 39 | 40 | // @override 41 | // Widget build(BuildContext context) { 42 | // return LayoutBuilder(builder: (context, constraints) { 43 | // if (constraints.maxWidth < _maxWidth) { 44 | // return mobileView; 45 | // } else { 46 | // return desktopView; 47 | // } 48 | // }); 49 | // } 50 | } 51 | -------------------------------------------------------------------------------- /lib/Presentation/login/bloc/login_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app_preferences.dart'; 2 | import 'package:basic_architecture/Domain/usecase/login_usecase.dart'; 3 | import 'package:basic_architecture/Presentation/login/forms/id_input.dart'; 4 | import 'package:basic_architecture/Presentation/login/forms/password_input.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:equatable/equatable.dart'; 8 | import 'package:formz/formz.dart'; 9 | import 'package:injectable/injectable.dart'; 10 | 11 | part 'login_event.dart'; 12 | part 'login_state.dart'; 13 | 14 | @injectable 15 | class LoginBloc extends Bloc { 16 | final AppPreferences _appPreferences; 17 | final LoginUseCase _loginUseCase; 18 | 19 | LoginBloc(this._appPreferences, this._loginUseCase) 20 | : super(const LoginState( 21 | id: IDInput.pure(), 22 | password: PasswordInput.pure(), 23 | status: FormzSubmissionStatus.initial)) { 24 | on(_onIDChanged); 25 | on(_onPasswordChanged); 26 | on(_onSubmitted); 27 | } 28 | 29 | void _onIDChanged( 30 | IDChanged event, 31 | Emitter emit, 32 | ) { 33 | final id = IDInput.dirty(event.id); 34 | emit( 35 | state.copyWith( 36 | id: id, 37 | isValid: Formz.validate([state.password, id]), 38 | ), 39 | ); 40 | } 41 | 42 | void _onPasswordChanged( 43 | PasswordChanged event, 44 | Emitter emit, 45 | ) { 46 | final password = PasswordInput.dirty(event.password); 47 | emit( 48 | state.copyWith( 49 | password: password, 50 | isValid: Formz.validate([password, state.id]), 51 | ), 52 | ); 53 | } 54 | 55 | Future _onSubmitted( 56 | Submitted event, 57 | Emitter emit, 58 | ) async { 59 | if (state.isValid) { 60 | emit(state.copyWith(status: FormzSubmissionStatus.inProgress)); 61 | try { 62 | (await _loginUseCase.execute( 63 | LoginUseCaseInput(state.id.value, state.password.value))) 64 | .fold((left) { 65 | emit(state.copyWith( 66 | status: FormzSubmissionStatus.failure, errorMessage: left)); 67 | }, (right) { 68 | _appPreferences.login(); 69 | emit(state.copyWith(status: FormzSubmissionStatus.success)); 70 | }); 71 | } catch (_) { 72 | emit(state.copyWith(status: FormzSubmissionStatus.failure)); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/Presentation/login/bloc/login_event.dart: -------------------------------------------------------------------------------- 1 | part of 'login_bloc.dart'; 2 | 3 | @immutable 4 | abstract class LoginEvent extends Equatable { 5 | @override 6 | List get props => []; 7 | } 8 | 9 | class IDChanged extends LoginEvent { 10 | final String id; 11 | IDChanged(this.id); 12 | 13 | @override 14 | List get props => [id]; 15 | } 16 | 17 | class PasswordChanged extends LoginEvent { 18 | final String password; 19 | PasswordChanged(this.password); 20 | 21 | @override 22 | List get props => [password]; 23 | } 24 | 25 | class Submitted extends LoginEvent { 26 | Submitted(); 27 | } 28 | -------------------------------------------------------------------------------- /lib/Presentation/login/bloc/login_state.dart: -------------------------------------------------------------------------------- 1 | part of 'login_bloc.dart'; 2 | 3 | final class LoginState extends Equatable { 4 | final IDInput id; 5 | final PasswordInput password; 6 | final FormzSubmissionStatus status; 7 | final bool isValid; 8 | final String? errorMessage; 9 | 10 | const LoginState( 11 | {required this.id, 12 | required this.password, 13 | required this.status, 14 | this.errorMessage, 15 | this.isValid = false}); 16 | 17 | LoginState copyWith({ 18 | IDInput? id, 19 | PasswordInput? password, 20 | FormzSubmissionStatus? status, 21 | bool? isValid, 22 | final String? errorMessage 23 | }) { 24 | return LoginState( 25 | id: id ?? this.id, 26 | password: password ?? this.password, 27 | status: status ?? this.status, 28 | isValid: isValid ?? this.isValid, 29 | errorMessage: errorMessage 30 | ); 31 | } 32 | 33 | @override 34 | List get props => [status, id, password]; 35 | } 36 | -------------------------------------------------------------------------------- /lib/Presentation/login/forms/id_input.dart: -------------------------------------------------------------------------------- 1 | import 'package:formz/formz.dart'; 2 | 3 | class IDInput extends FormzInput { 4 | const IDInput.pure() : super.pure(''); 5 | 6 | const IDInput.dirty(String value) : super.dirty(value); 7 | 8 | @override 9 | String? validator(String value) { 10 | if (value.isEmpty || value.length < 2) return 'Please enter your ID.'; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/Presentation/login/forms/password_input.dart: -------------------------------------------------------------------------------- 1 | import 'package:formz/formz.dart'; 2 | 3 | class PasswordInput extends FormzInput { 4 | const PasswordInput.pure() : super.pure(''); 5 | 6 | const PasswordInput.dirty(String value) : super.dirty(value); 7 | 8 | @override 9 | String? validator(String value) { 10 | if (value.isEmpty) return 'Please enter your password.'; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/Presentation/login/view/login_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Presentation/authentication/bloc/authentication_bloc.dart'; 2 | import 'package:basic_architecture/Presentation/login/bloc/login_bloc.dart'; 3 | import 'package:basic_architecture/Presentation/routes_manager.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_bloc/flutter_bloc.dart'; 6 | import 'package:formz/formz.dart'; 7 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 8 | 9 | class LoginView extends StatefulWidget { 10 | const LoginView({super.key}); 11 | 12 | @override 13 | State createState() => _LoginViewState(); 14 | } 15 | 16 | class _LoginViewState extends State { 17 | Widget _loginWidget() { 18 | return Scaffold( 19 | backgroundColor: Colors.white, 20 | body: SingleChildScrollView( 21 | child: Column( 22 | children: [ 23 | Padding( 24 | padding: const EdgeInsets.only(top: 60.0), 25 | child: Center( 26 | child: SizedBox( 27 | width: 300, 28 | height: 150, 29 | child: Image.asset('assets/images/flutter-logo.png')), 30 | ), 31 | ), 32 | Padding( 33 | //padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0), 34 | padding: const EdgeInsets.symmetric(horizontal: 15), 35 | child: BlocBuilder( 36 | // 현재 아이디 입력 상태의 유효성 체크가 이전 아이디 입력 상태 유효성 체크와 다른 경우 일때만 빌드 한다. 37 | buildWhen: (prev, cur) => prev.id.isValid != cur.id.isValid, 38 | builder: (context, state) { 39 | return TextField( 40 | decoration: InputDecoration( 41 | border: const OutlineInputBorder(), 42 | labelText: 'ID', 43 | hintText: 'Enter your ID', 44 | errorText: state.id.displayError), 45 | onChanged: (id) => 46 | context.read().add(IDChanged(id)), 47 | ); 48 | }), 49 | ), 50 | Padding( 51 | padding: const EdgeInsets.only( 52 | left: 15.0, right: 15.0, top: 15, bottom: 0), 53 | child: BlocBuilder( 54 | buildWhen: (prev, cur) => 55 | prev.password.isValid != cur.password.isValid, 56 | builder: (context, state) { 57 | return TextField( 58 | obscureText: true, 59 | decoration: InputDecoration( 60 | border: const OutlineInputBorder(), 61 | labelText: 'Password', 62 | hintText: 'Enter secure password', 63 | errorText: state.password.displayError), 64 | onChanged: (id) => 65 | context.read().add(PasswordChanged(id)), 66 | ); 67 | }), 68 | ), 69 | TextButton( 70 | onPressed: () { 71 | // TODO : FORGOT PASSWORD SCREEN GOES HERE 72 | }, 73 | child: Text( 74 | AppLocalizations.of(context)!.forgotPassword, 75 | style: const TextStyle(color: Colors.blue, fontSize: 15), 76 | ), 77 | ), 78 | Container( 79 | height: 50, 80 | width: 250, 81 | decoration: BoxDecoration( 82 | color: Colors.blue, borderRadius: BorderRadius.circular(20)), 83 | child: Builder(builder: (context) { 84 | return BlocConsumer( 85 | buildWhen: (prev, cur) => prev.status != cur.status, 86 | builder: (context, state) { 87 | return TextButton( 88 | onPressed: state.status == 89 | FormzSubmissionStatus.inProgress 90 | ? null 91 | : () => context.read().add(Submitted()), 92 | child: (state.status == FormzSubmissionStatus.inProgress) 93 | ? const CircularProgressIndicator() 94 | : Text( 95 | AppLocalizations.of(context)!.login, 96 | style: const TextStyle( 97 | color: Colors.white, fontSize: 25), 98 | ), 99 | ); 100 | }, 101 | listenWhen: (prev, cur) => prev.status != cur.status, 102 | listener: (BuildContext context, LoginState state) { 103 | if (state.status == FormzSubmissionStatus.success) { 104 | Navigator.of(context) 105 | .pushReplacementNamed(Routes.splashRoute); 106 | } else { 107 | ScaffoldMessenger.of(context) 108 | ..hideCurrentSnackBar() 109 | ..showSnackBar( 110 | SnackBar( 111 | content: Text(state.errorMessage ?? ''), 112 | duration: const Duration( 113 | milliseconds: 2500, 114 | )), 115 | ); 116 | } 117 | }, 118 | ); 119 | }), 120 | ), 121 | const SizedBox( 122 | height: 130, 123 | ), 124 | const Text('New User? Create Account') 125 | ], 126 | ), 127 | ), 128 | ); 129 | } 130 | 131 | @override 132 | Widget build(BuildContext context) => 133 | BlocConsumer( 134 | listener: (context, state) { 135 | // 136 | }, 137 | builder: (context, state) => _loginWidget(), 138 | ); 139 | } 140 | -------------------------------------------------------------------------------- /lib/Presentation/routes_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Injectable/configurations.dart'; 2 | import 'package:basic_architecture/Presentation/authentication/bloc/authentication_bloc.dart'; 3 | import 'package:basic_architecture/Presentation/home/view/app_view.dart'; 4 | import 'package:basic_architecture/Presentation/login/bloc/login_bloc.dart'; 5 | import 'package:basic_architecture/Presentation/login/view/login_view.dart'; 6 | import 'package:basic_architecture/Presentation/splash/splash.dart'; 7 | import 'package:basic_architecture/Presentation/subscription_info/bloc/subscription_info_bloc.dart'; 8 | import 'package:basic_architecture/Presentation/subscription_info/view/subscription_info_view.dart'; 9 | import 'package:flutter/material.dart'; 10 | import 'package:flutter_bloc/flutter_bloc.dart'; 11 | 12 | class Routes { 13 | static const String splashRoute = "/splash"; 14 | static const String loginRoute = "/login"; 15 | static const String mainRoute = "/main"; 16 | static const String subscriptionKeyInfoRoute = "/subscriptionKeyInfo"; 17 | } 18 | 19 | class RouteGenerator { 20 | static Route getRoute(RouteSettings settings) { 21 | switch (settings.name) { 22 | case Routes.splashRoute: 23 | var authBloc = getIt(); 24 | return MaterialPageRoute( 25 | builder: (_) => BlocProvider.value( 26 | value: authBloc, 27 | child: const SplashView(), 28 | )); 29 | case Routes.loginRoute: 30 | var loginBloc = getIt(); 31 | return MaterialPageRoute( 32 | builder: (_) => BlocProvider.value( 33 | value: loginBloc, 34 | child: const LoginView(), 35 | )); 36 | case Routes.mainRoute: 37 | return MaterialPageRoute(builder: (_) => const AppView()); 38 | case Routes.subscriptionKeyInfoRoute: 39 | var subscriptionInfoBloc = getIt(); 40 | return MaterialPageRoute( 41 | builder: (_) => BlocProvider.value( 42 | value: subscriptionInfoBloc, 43 | child: const SubscriptionInfoView(), 44 | )); 45 | default: 46 | return unDefinedRoute(); 47 | } 48 | } 49 | 50 | static Route unDefinedRoute() { 51 | return MaterialPageRoute( 52 | builder: (_) => Scaffold( 53 | appBar: AppBar( 54 | title: const Text( 55 | "찾을 수 없는 페이지 (page not found)", 56 | ), 57 | ), 58 | body: const Center( 59 | child: Text("찾을 수 없는 페이지 (page not found)"), 60 | ), 61 | )); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/Presentation/splash/splash.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:basic_architecture/Presentation/authentication/bloc/authentication_bloc.dart'; 4 | import 'package:basic_architecture/Presentation/routes_manager.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | 8 | class SplashView extends StatefulWidget { 9 | const SplashView({super.key}); 10 | 11 | @override 12 | State createState() => _SplashViewState(); 13 | } 14 | 15 | class _SplashViewState extends State { 16 | @override 17 | void initState() { 18 | super.initState(); 19 | 20 | context 21 | .read() 22 | .add(AuthenticationStatusChanged(AuthenticationStatus.loading)); 23 | } 24 | 25 | @override 26 | Widget build(BuildContext context) => 27 | BlocListener( 28 | listener: (context, state) { 29 | if (state.status == AuthenticationStatus.authenticated) { 30 | Navigator.of(context).pushReplacementNamed(Routes.mainRoute); 31 | } else if (state.status == AuthenticationStatus.loading) { 32 | // 33 | } else { 34 | Navigator.of(context).pushReplacementNamed(Routes.loginRoute); 35 | } 36 | }, 37 | // 보통 앱의 로고를 표시하고, 인증 여부를 체크 한다. 38 | // 인증 토큰을 로컬 캐시에 보관하고, 토큰 유효성 검사 성공인 경우 Main home page로 이동 39 | // 인증 토큰이 존재 하지 않거나, 토큰 유효성 검사 실패인 경우 Login page로 이동 40 | child: const Center( 41 | child: CircularProgressIndicator(), 42 | )); 43 | } 44 | -------------------------------------------------------------------------------- /lib/Presentation/subscription_info/bloc/subscription_info_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app_preferences.dart'; 2 | import 'package:basic_architecture/Domain/models/subscription_key.dart'; 3 | import 'package:basic_architecture/Domain/usecase/subscription_key_info_usecase.dart'; 4 | import 'package:equatable/equatable.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:injectable/injectable.dart'; 8 | 9 | part 'subscription_info_event.dart'; 10 | part 'subscription_info_state.dart'; 11 | 12 | @injectable 13 | class SubscriptionInfoBloc 14 | extends Bloc { 15 | final AppPreferences _appPreferences; 16 | final SubscriptionKeyInfoUseCase _subscriptionKeyInfoUseCase; 17 | 18 | SubscriptionInfoBloc(this._appPreferences, this._subscriptionKeyInfoUseCase) 19 | : super(const LoadingState()) { 20 | on(_onGetSubscriptionInfoEvent); 21 | } 22 | 23 | Future _onGetSubscriptionInfoEvent( 24 | GetSubscriptionInfoEvent event, 25 | Emitter emit, 26 | ) async { 27 | // 데이터 요청중 28 | emit(const LoadingState()); 29 | 30 | // 임의로 1초 딜레이 31 | await Future.delayed(const Duration(seconds: 1)); 32 | 33 | var subscriptionKeyInfo = await _subscriptionKeyInfoUseCase.execute(null); 34 | subscriptionKeyInfo.fold( 35 | (left) => emit(const ErrorState()), 36 | (right) => emit(LoadedState(right)), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/Presentation/subscription_info/bloc/subscription_info_event.dart: -------------------------------------------------------------------------------- 1 | part of 'subscription_info_bloc.dart'; 2 | 3 | @immutable 4 | abstract class SubscriptionInfoEvent extends Equatable { 5 | @override 6 | List get props => []; 7 | } 8 | 9 | final class GetSubscriptionInfoEvent extends SubscriptionInfoEvent {} 10 | -------------------------------------------------------------------------------- /lib/Presentation/subscription_info/bloc/subscription_info_state.dart: -------------------------------------------------------------------------------- 1 | part of 'subscription_info_bloc.dart'; 2 | 3 | enum DataLoadStatus { 4 | // 데이터 없음 5 | empty, 6 | // 로딩중 7 | loading, 8 | // 데이터 요청 오류 9 | error, 10 | // 로드 완료 11 | loaded, 12 | } 13 | 14 | abstract class SubscriptionInfoState extends Equatable { 15 | final DataLoadStatus status; 16 | final SubscriptionKey? subscriptionKeyInfo; 17 | 18 | const SubscriptionInfoState(this.status, {this.subscriptionKeyInfo}); 19 | 20 | @override 21 | List get props => [status, subscriptionKeyInfo]; 22 | } 23 | 24 | /// 데이터 없음 25 | class EmptyDataState extends SubscriptionInfoState { 26 | const EmptyDataState() : super(DataLoadStatus.empty); 27 | } 28 | 29 | /// 데이터 요청중 30 | class LoadingState extends SubscriptionInfoState { 31 | const LoadingState() : super(DataLoadStatus.loading); 32 | } 33 | 34 | /// 데이터 요청 오류 35 | class ErrorState extends SubscriptionInfoState { 36 | const ErrorState() : super(DataLoadStatus.error); 37 | } 38 | 39 | /// 로드 완료 40 | class LoadedState extends SubscriptionInfoState { 41 | final SubscriptionKey? _subscriptionKey; 42 | const LoadedState(this._subscriptionKey) 43 | : super(DataLoadStatus.loaded, subscriptionKeyInfo: _subscriptionKey); 44 | } 45 | -------------------------------------------------------------------------------- /lib/Presentation/subscription_info/view/subscription_info_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/Presentation/subscription_info/bloc/subscription_info_bloc.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_bloc/flutter_bloc.dart'; 4 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 5 | 6 | class SubscriptionInfoView extends StatefulWidget { 7 | const SubscriptionInfoView({super.key}); 8 | 9 | @override 10 | State createState() => _SubscriptionInfoViewState(); 11 | } 12 | 13 | class _SubscriptionInfoViewState extends State { 14 | @override 15 | void initState() { 16 | super.initState(); 17 | 18 | context.read().add(GetSubscriptionInfoEvent()); 19 | } 20 | 21 | Widget _bodyWidget() { 22 | return BlocBuilder( 23 | buildWhen: (prev, cur) => prev != cur, 24 | builder: (context, state) { 25 | if (state is EmptyDataState) { 26 | return const Text('No data.', 27 | style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)); 28 | } else if (state is LoadingState) { 29 | return const Center( 30 | child: CircularProgressIndicator( 31 | color: Color.fromARGB(255, 252, 113, 49))); 32 | } else if (state is LoadedState) { 33 | // 로드 완료 데이터 34 | final subscriptionKeyInfo = state.subscriptionKeyInfo; 35 | 36 | if (subscriptionKeyInfo == null) { 37 | return const Center( 38 | child: Text( 39 | 'There is no subscription information for your current login account.', 40 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), 41 | ); 42 | } 43 | 44 | return Center( 45 | child: Column( 46 | children: [ 47 | Row( 48 | children: [ 49 | Text('${AppLocalizations.of(context)!.subscriptionKey} : ', 50 | style: const TextStyle( 51 | fontSize: 16, fontWeight: FontWeight.bold)), 52 | Text(subscriptionKeyInfo.key, 53 | style: const TextStyle(fontSize: 16)), 54 | ], 55 | ), 56 | Row( 57 | children: [ 58 | Text('${AppLocalizations.of(context)!.subscriptionType} : ', 59 | style: const TextStyle( 60 | fontSize: 16, fontWeight: FontWeight.bold)), 61 | Text(subscriptionKeyInfo.keyType, 62 | style: const TextStyle(fontSize: 16)), 63 | ], 64 | ), 65 | Row( 66 | children: [ 67 | Text( 68 | '${AppLocalizations.of(context)!.subscriptionStartDT} : ', 69 | style: const TextStyle( 70 | fontSize: 16, fontWeight: FontWeight.bold)), 71 | Text(subscriptionKeyInfo.startDT.toString(), 72 | style: const TextStyle(fontSize: 16)), 73 | ], 74 | ), 75 | Row( 76 | children: [ 77 | Text( 78 | '${AppLocalizations.of(context)!.subscriptionEndDT} : ', 79 | style: const TextStyle( 80 | fontSize: 16, fontWeight: FontWeight.bold)), 81 | Text(subscriptionKeyInfo.endDT.toString(), 82 | style: const TextStyle(fontSize: 16)), 83 | ], 84 | ), 85 | Row( 86 | children: [ 87 | Text('${AppLocalizations.of(context)!.subscriptionMemo} : ', 88 | style: const TextStyle( 89 | fontSize: 16, fontWeight: FontWeight.bold)), 90 | Text(subscriptionKeyInfo.memo, 91 | style: const TextStyle(fontSize: 16)), 92 | ], 93 | ), 94 | ], 95 | ), 96 | ); 97 | } else { 98 | return const Text('Error loading data', 99 | style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)); 100 | } 101 | }, 102 | ); 103 | } 104 | 105 | @override 106 | Widget build(BuildContext context) { 107 | return Scaffold( 108 | appBar: AppBar( 109 | title: Text( 110 | AppLocalizations.of(context)!.subscriptionKeyInfo, 111 | style: const TextStyle(color: Colors.white, fontSize: 25), 112 | ), 113 | ), 114 | body: _bodyWidget(), 115 | ); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lib/config.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 3 | 4 | /// l10n\arb에서 문자열 지역화 를 정의. 5 | /// Define string localization in l10n\arb. 6 | 7 | enum Language { en, ko } 8 | 9 | extension LanguageExtension on Language { 10 | String get code { 11 | switch (this) { 12 | case Language.en: 13 | return 'en'; 14 | case Language.ko: 15 | return 'ko'; 16 | } 17 | } 18 | 19 | Locale get locale => Locale(code); 20 | } 21 | -------------------------------------------------------------------------------- /lib/l10n/arb/app_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | "login": "Login", 3 | "noRouteFound": "page not found", 4 | "forgotPassword": "Forgot Password", 5 | "subscriptionKeyInfo": "Subscription key info", 6 | "subscriptionKey": "Subscription Key", 7 | "subscriptionType": "Subscription Type", 8 | "subscriptionStartDT": "Subscription start date", 9 | "subscriptionEndDT": "Subscription end date", 10 | "subscriptionMemo": "Memo" 11 | } -------------------------------------------------------------------------------- /lib/l10n/arb/app_ko.arb: -------------------------------------------------------------------------------- 1 | { 2 | "login": "로그인", 3 | "noRouteFound": "찾을 수 없는 페이지", 4 | "forgotPassword": "패스워드 찾기", 5 | "subscriptionKeyInfo": "구독키 정보", 6 | "subscriptionKey": "구독 키", 7 | "subscriptionType": "구독 타입", 8 | "subscriptionStartDT": "구독 시작일", 9 | "subscriptionEndDT": "구독 종료일", 10 | "subscriptionMemo": "메모" 11 | } -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:basic_architecture/App/app.dart'; 2 | import 'package:basic_architecture/Injectable/configurations.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | main() => App.run(); 6 | 7 | class App { 8 | App(); 9 | 10 | static Future run() async { 11 | WidgetsFlutterBinding.ensureInitialized(); 12 | await configureDependencies(); 13 | runApp(const MyApp()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "basic_architecture") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.basic_architecture") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | 90 | # Generated plugin build rules, which manage building the plugins and adding 91 | # them to the application. 92 | include(flutter/generated_plugins.cmake) 93 | 94 | 95 | # === Installation === 96 | # By default, "installing" just makes a relocatable bundle in the build 97 | # directory. 98 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 99 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 100 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 101 | endif() 102 | 103 | # Start with a clean build bundle directory every time. 104 | install(CODE " 105 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 106 | " COMPONENT Runtime) 107 | 108 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 109 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 110 | 111 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 112 | COMPONENT Runtime) 113 | 114 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 115 | COMPONENT Runtime) 116 | 117 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 118 | COMPONENT Runtime) 119 | 120 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 121 | install(FILES "${bundled_library}" 122 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 123 | COMPONENT Runtime) 124 | endforeach(bundled_library) 125 | 126 | # Copy the native assets provided by the build.dart from all packages. 127 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 128 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 129 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 130 | COMPONENT Runtime) 131 | 132 | # Fully re-copy the assets directory on each build to avoid having stale files 133 | # from a previous install. 134 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 135 | install(CODE " 136 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 137 | " COMPONENT Runtime) 138 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 139 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 140 | 141 | # Install the AOT library on non-Debug builds only. 142 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 143 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 144 | COMPONENT Runtime) 145 | endif() 146 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); 14 | flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_secure_storage_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "basic_architecture"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "basic_architecture"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import flutter_secure_storage_macos 9 | import path_provider_foundation 10 | import shared_preferences_foundation 11 | 12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 13 | FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) 14 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 15 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 16 | } 17 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = basic_architecture 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.basicArchitecture 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: basic_architecture 2 | description: "A new Flutter project." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: '>=3.2.0 <4.0.0' 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | 34 | get_it: ^7.6.4 # DI(의존성 주입) 패키지 35 | injectable: ^2.3.2 # get_it DI code generator 패키지 36 | flutter_bloc: ^8.1.3 # 상태관리 패키지 37 | dio: ^5.3.3 # 클라이언트 http 요청 패키지 38 | pretty_dio_logger: ^1.3.1 # dio 로그 패키지 39 | equatable: ^2.0.5 # 객체 비교 패키지 (주로 bloc state에서 사용되어 bloc 빌드 최적화시 상태 비교에 사용) 40 | dartz: ^0.10.1 # Either 타입 제공 패키지 (주로 UseCase에서 Input에 대한 Ouput를 성공(Right) 또는 실패(Left)로 반환 받아 사용 된다.) 41 | json_annotation: ^4.8.1 # 객체 JsonSerializable 패키지 (어노테이션으로 제공) 42 | json_serializable: ^6.7.1 43 | retrofit: ^4.0.3 # dio 패키지를 사용한 http 요청 code generator 패키지 44 | formz: ^0.6.1 # 입력 폼(TextField 등)에 사용자 입력 값에 대한 유효성 검사 제공 패키지 45 | shared_preferences: ^2.2.2 # shared preferences 패키지 46 | flutter_secure_storage: ^9.0.0 # secure storage 패키지 (API의 인증 Access token, refresh token 등 보관 용도) 47 | flutter_speed_dial: ^6.2.0 # 햄버거 버튼 터치시 서브 메뉴 표시 처리 패키지 48 | bottom_sheet: ^4.0.0 # 하단에 위젯 표시 처리 패키지 49 | shimmer: ^3.0.0 # 로딩 효과 패키지 50 | 51 | 52 | # The following adds the Cupertino Icons font to your application. 53 | # Use with the CupertinoIcons class for iOS style icons. 54 | cupertino_icons: ^1.0.2 55 | flutter_localizations: # 다국어 패키지 56 | sdk: flutter 57 | intl: any # 포맷 패키지 58 | 59 | dev_dependencies: 60 | flutter_test: 61 | sdk: flutter 62 | 63 | injectable_generator: # injectable code generator 64 | retrofit_generator: # retrofit code generator 65 | build_runner: 66 | 67 | # The "flutter_lints" package below contains a set of recommended lints to 68 | # encourage good coding practices. The lint set provided by the package is 69 | # activated in the `analysis_options.yaml` file located at the root of your 70 | # package. See that file for information about deactivating specific lint 71 | # rules and activating additional ones. 72 | flutter_lints: ^2.0.0 73 | 74 | # For information on the generic Dart part of this file, see the 75 | # following page: https://dart.dev/tools/pub/pubspec 76 | 77 | # The following section is specific to Flutter packages. 78 | flutter: 79 | 80 | # The following line ensures that the Material Icons font is 81 | # included with your application, so that you can use the icons in 82 | # the material Icons class. 83 | uses-material-design: true 84 | generate: true 85 | 86 | # To add assets to your application, add an assets section, like this: 87 | assets: 88 | - assets/images/ 89 | 90 | # An image asset can refer to one or more resolution-specific "variants", see 91 | # https://flutter.dev/assets-and-images/#resolution-aware 92 | 93 | # For details regarding adding assets from package dependencies, see 94 | # https://flutter.dev/assets-and-images/#from-packages 95 | 96 | # To add custom fonts to your application, add a fonts section here, 97 | # in this "flutter" section. Each entry in this list should have a 98 | # "family" key with the font family name, and a "fonts" key with a 99 | # list giving the asset and other descriptors for the font. For 100 | # example: 101 | # fonts: 102 | # - family: Schyler 103 | # fonts: 104 | # - asset: fonts/Schyler-Regular.ttf 105 | # - asset: fonts/Schyler-Italic.ttf 106 | # style: italic 107 | # - family: Trajan Pro 108 | # fonts: 109 | # - asset: fonts/TrajanPro.ttf 110 | # - asset: fonts/TrajanPro_Bold.ttf 111 | # weight: 700 112 | # 113 | # For details regarding fonts from package dependencies, 114 | # see https://flutter.dev/custom-fonts/#from-packages 115 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:basic_architecture/App/app.dart'; 9 | import 'package:flutter/material.dart'; 10 | import 'package:flutter_test/flutter_test.dart'; 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(const MyApp()); 16 | 17 | // Verify that our counter starts at 0. 18 | expect(find.text('0'), findsOneWidget); 19 | expect(find.text('1'), findsNothing); 20 | 21 | // Tap the '+' icon and trigger a frame. 22 | await tester.tap(find.byIcon(Icons.add)); 23 | await tester.pump(); 24 | 25 | // Verify that our counter has incremented. 26 | expect(find.text('0'), findsNothing); 27 | expect(find.text('1'), findsOneWidget); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | basic_architecture 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic_architecture", 3 | "short_name": "basic_architecture", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(basic_architecture LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "basic_architecture") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | FlutterSecureStorageWindowsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_secure_storage_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "basic_architecture" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "basic_architecture" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "basic_architecture.exe" "\0" 98 | VALUE "ProductName", "basic_architecture" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"basic_architecture", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyeom/flutter_basic_architecture/d7728c83e5c123f67eca63a3a1330f51097d5e72/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | --------------------------------------------------------------------------------