├── .gitignore
├── .metadata
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── flutter_ddd
│ │ │ │ └── MainActivity.kt
│ │ └── res
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── doc
└── images
│ └── screencast.gif
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Podfile
├── Podfile.lock
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── 100.png
│ │ ├── 1024.png
│ │ ├── 114.png
│ │ ├── 120.png
│ │ ├── 144.png
│ │ ├── 152.png
│ │ ├── 167.png
│ │ ├── 180.png
│ │ ├── 20.png
│ │ ├── 29.png
│ │ ├── 40.png
│ │ ├── 50.png
│ │ ├── 57.png
│ │ ├── 58.png
│ │ ├── 60.png
│ │ ├── 72.png
│ │ ├── 76.png
│ │ ├── 80.png
│ │ ├── 87.png
│ │ └── Contents.json
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LaunchImage@3x.png
│ │ └── README.md
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── Runner-Bridging-Header.h
├── lib
├── application
│ ├── category_app_service.dart
│ ├── dto
│ │ ├── category_dto.dart
│ │ ├── note_dto.dart
│ │ └── note_summary_dto.dart
│ └── note_app_service.dart
├── common
│ └── exception.dart
├── domain
│ ├── category
│ │ ├── category.dart
│ │ ├── category_factory_base.dart
│ │ ├── category_repository_base.dart
│ │ ├── category_service.dart
│ │ └── value
│ │ │ ├── category_id.dart
│ │ │ └── category_name.dart
│ └── note
│ │ ├── note.dart
│ │ ├── note_factory_base.dart
│ │ ├── note_repository_base.dart
│ │ ├── note_service.dart
│ │ └── value
│ │ ├── note_body.dart
│ │ ├── note_id.dart
│ │ └── note_title.dart
├── infrastructure
│ ├── category
│ │ ├── category_factory.dart
│ │ └── category_repository.dart
│ ├── db_helper.dart
│ └── note
│ │ ├── note_factory.dart
│ │ └── note_repository.dart
├── init.dart
├── main.dart
└── presentation
│ ├── notifier
│ ├── category_notifier.dart
│ └── note_notifier.dart
│ ├── page
│ ├── category_list.dart
│ ├── init.dart
│ └── note_list.dart
│ └── widget
│ ├── category
│ ├── add_button.dart
│ ├── category_list_view.dart
│ ├── edit_button.dart
│ ├── edit_dialog.dart
│ ├── remove_button.dart
│ └── remove_dialog.dart
│ ├── error_dialog.dart
│ └── note
│ ├── add_button.dart
│ ├── dropdown.dart
│ ├── edit_button.dart
│ ├── edit_dialog.dart
│ ├── note_list_view.dart
│ ├── remove_button.dart
│ └── remove_dialog.dart
├── pubspec.lock
├── pubspec.yaml
└── test
├── category_app_service_test.dart
├── infrastructure
├── category_repository.dart
└── note_repository.dart
└── note_app_service_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | /build/
32 |
33 | # Web related
34 | lib/generated_plugin_registrant.dart
35 |
36 | # Exceptions to above rules.
37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
38 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 kaboc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # flutter_ddd
2 |
3 | Notes app sample in Dart / Flutter with DDD.
4 |
5 | 
6 |
7 | This is an outcome of my attempt to understand Domain-Driven Design and consider how I can introduce
8 | it to app development in Flutter. The attempt began when I wondered what directory structure would be
9 | better and started to try to figure it out.
10 |
11 | DDD may be too much for a small app like this, resulting in unnecessarily bloated code, but should
12 | help you more in development of larger apps.
13 |
14 | ## Branches
15 |
16 | * master (current branch)
17 | * The original example with ChangeNotifier
18 | * [state_notifier](https://github.com/kaboc/flutter_ddd/tree/state_notifier)
19 | * A newer example with StateNotifier (w/o Freezed)
20 | * I tried this to see if it could make things easier, but unfortunately I did not really see
21 | benefits from just separating states from notifiers and making the states immutable in this
22 | project. It may matter more in other projects.
23 |
24 | ## Related articles
25 |
26 | - [Dart/Flutterでドメイン駆動設計(DDD)してみた - 導入編](https://kabochapo.hateblo.jp/entry/2019/11/01/195130) (Japanese)
27 | - This post describes what DDD and architectures are like and what structure I chose.
28 | - [Dart/Flutterでドメイン駆動設計(DDD)してみた - 実装編](https://kabochapo.hateblo.jp/entry/2019/11/21/160759) (Japanese)
29 | - This shows what I considered in implementing DDD in Dart / Flutter.
30 |
31 | ## References
32 |
33 | - [Book: 現場で役立つシステム設計の原則](https://gihyo.jp/book/2017/978-4-7741-9087-7)
34 | - [ボトムアップドメイン駆動設計 │ nrslib](https://nrslib.com/bottomup-ddd/)
35 | - [ボトムアップドメイン駆動設計 後編 │ nrslib](https://nrslib.com/bottomup-ddd-2/)
36 | - [「DDDのモデリングとは何なのか、 そしてどうコードに落とすのか」資料 / Q&A - little hands' lab](https://little-hands.hatenablog.com/entry/2019/08/31/genba_de_ddd)
37 | - [ドメイン駆動設計(DDD) カテゴリーの記事一覧 - little hands' lab](https://little-hands.hatenablog.com/archive/category/%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3%E9%A7%86%E5%8B%95%E8%A8%AD%E8%A8%88%28DDD%29)
38 |
39 | ## Credits
40 |
41 | * Icon by [Hamza Saleem](http://www.hamzasaleem.co.uk/), taken from [IconArchive.com](http://www.iconarchive.com/show/stock-style-3-icons-by-hamzasaleem/Notes-icon.html)
42 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # Specify analysis options.
2 | #
3 | # Until there are meta linter rules, each desired lint must be explicitly enabled.
4 | # See: https://github.com/dart-lang/linter/issues/288
5 | #
6 | # For a list of lints, see: http://dart-lang.github.io/linter/lints/
7 | # See the configuration guide for more
8 | # https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
9 | #
10 | # There are other similar analysis options files in the flutter repos,
11 | # which should be kept in sync with this file:
12 | #
13 | # - analysis_options.yaml (this file)
14 | # - packages/flutter/lib/analysis_options_user.yaml
15 | # - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
16 | # - https://github.com/flutter/engine/blob/master/analysis_options.yaml
17 | #
18 | # This file contains the analysis options used by Flutter tools, such as IntelliJ,
19 | # Android Studio, and the `flutter analyze` command.
20 |
21 | analyzer:
22 | strong-mode:
23 | implicit-casts: false
24 | implicit-dynamic: false
25 | errors:
26 | # treat missing required parameters as a warning (not a hint)
27 | missing_required_param: error
28 | # treat missing returns as a warning (not a hint)
29 | missing_return: warning
30 | # allow having TODOs in the code
31 | todo: ignore
32 | # Ignore analyzer hints for updating pubspecs when using Future or
33 | # Stream and not importing dart:async
34 | # Please see https://github.com/flutter/flutter/pull/24528 for details.
35 | sdk_version_async_exported_from_core: ignore
36 | exclude:
37 | - "bin/cache/**"
38 | # the following two are relative to the stocks example and the flutter package respectively
39 | # see https://github.com/dart-lang/sdk/issues/28463
40 | - "lib/i18n/messages_*.dart"
41 | - "lib/src/http/**"
42 |
43 | linter:
44 | rules:
45 | # these rules are documented on and in the same order as
46 | # the Dart Lint rules page to make maintenance easier
47 | # https://github.com/dart-lang/linter/blob/master/example/all.yaml
48 | - always_declare_return_types
49 | - always_put_control_body_on_new_line
50 | # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
51 | - always_require_non_null_named_parameters
52 | # - always_specify_types
53 | - annotate_overrides
54 | # - avoid_annotating_with_dynamic # conflicts with always_specify_types
55 | # - avoid_as # required for implicit-casts: true
56 | - avoid_bool_literals_in_conditional_expressions
57 | # - avoid_catches_without_on_clauses # we do this commonly
58 | # - avoid_catching_errors # we do this commonly
59 | - avoid_classes_with_only_static_members
60 | # - avoid_double_and_int_checks # only useful when targeting JS runtime
61 | - avoid_empty_else
62 | - avoid_equals_and_hash_code_on_mutable_classes
63 | - avoid_field_initializers_in_const_classes
64 | - avoid_function_literals_in_foreach_calls
65 | # - avoid_implementing_value_types # not yet tested
66 | - avoid_init_to_null
67 | # - avoid_js_rounded_ints # only useful when targeting JS runtime
68 | - avoid_null_checks_in_equality_operators
69 | # - avoid_positional_boolean_parameters # not yet tested
70 | # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
71 | - avoid_relative_lib_imports
72 | - avoid_renaming_method_parameters
73 | - avoid_return_types_on_setters
74 | # - avoid_returning_null # there are plenty of valid reasons to return null
75 | # - avoid_returning_null_for_future # not yet tested
76 | - avoid_returning_null_for_void
77 | # - avoid_returning_this # there are plenty of valid reasons to return this
78 | # - avoid_setters_without_getters # not yet tested
79 | # - avoid_shadowing_type_parameters # not yet tested
80 | - avoid_single_cascade_in_expression_statements
81 | - avoid_slow_async_io
82 | - avoid_types_as_parameter_names
83 | # - avoid_types_on_closure_parameters # conflicts with always_specify_types
84 | - avoid_unused_constructor_parameters
85 | - avoid_void_async
86 | - await_only_futures
87 | - camel_case_extensions
88 | - camel_case_types
89 | - cancel_subscriptions
90 | # - cascade_invocations # not yet tested
91 | # - close_sinks # not reliable enough
92 | # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
93 | # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
94 | - control_flow_in_finally
95 | # - curly_braces_in_flow_control_structures # not yet tested
96 | # - diagnostic_describe_all_properties # not yet tested
97 | - directives_ordering
98 | - empty_catches
99 | - empty_constructor_bodies
100 | - empty_statements
101 | # - file_names # not yet tested
102 | - flutter_style_todos
103 | - hash_and_equals
104 | - implementation_imports
105 | # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
106 | - iterable_contains_unrelated_type
107 | # - join_return_with_assignment # not yet tested
108 | - library_names
109 | - library_prefixes
110 | # - lines_longer_than_80_chars # not yet tested
111 | - list_remove_unrelated_type
112 | # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
113 | - no_adjacent_strings_in_list
114 | - no_duplicate_case_values
115 | - non_constant_identifier_names
116 | # - null_closures # not yet tested
117 | # - omit_local_variable_types # opposite of always_specify_types
118 | # - one_member_abstracts # too many false positives
119 | # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
120 | - overridden_fields
121 | - package_api_docs
122 | - package_names
123 | - package_prefixed_library_names
124 | # - parameter_assignments # we do this commonly
125 | - prefer_adjacent_string_concatenation
126 | - prefer_asserts_in_initializer_lists
127 | # - prefer_asserts_with_message # not yet tested
128 | - prefer_collection_literals
129 | - prefer_conditional_assignment
130 | - prefer_const_constructors
131 | - prefer_const_constructors_in_immutables
132 | - prefer_const_declarations
133 | - prefer_const_literals_to_create_immutables
134 | # - prefer_constructors_over_static_methods # not yet tested
135 | - prefer_contains
136 | # - prefer_double_quotes # opposite of prefer_single_quotes
137 | - prefer_equal_for_default_values
138 | # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
139 | - prefer_final_fields
140 | - prefer_final_in_for_each
141 | - prefer_final_locals
142 | - prefer_for_elements_to_map_fromIterable
143 | - prefer_foreach
144 | # - prefer_function_declarations_over_variables # not yet tested
145 | - prefer_generic_function_type_aliases
146 | - prefer_if_elements_to_conditional_expressions
147 | - prefer_if_null_operators
148 | - prefer_initializing_formals
149 | - prefer_inlined_adds
150 | # - prefer_int_literals # not yet tested
151 | # - prefer_interpolation_to_compose_strings # not yet tested
152 | - prefer_is_empty
153 | - prefer_is_not_empty
154 | - prefer_is_not_operator
155 | - prefer_iterable_whereType
156 | # - prefer_mixin # https://github.com/dart-lang/language/issues/32
157 | # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
158 | - prefer_single_quotes
159 | - prefer_spread_collections
160 | - prefer_typing_uninitialized_variables
161 | - prefer_void_to_null
162 | # - provide_deprecation_message # not yet tested
163 | # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
164 | - recursive_getters
165 | - slash_for_doc_comments
166 | # - sort_child_properties_last # not yet tested
167 | # - sort_constructors_first
168 | - sort_pub_dependencies
169 | - sort_unnamed_constructors_first
170 | - test_types_in_equals
171 | - throw_in_finally
172 | # - type_annotate_public_apis # subset of always_specify_types
173 | - type_init_formals
174 | # - unawaited_futures # too many false positives
175 | # - unnecessary_await_in_return # not yet tested
176 | - unnecessary_brace_in_string_interps
177 | - unnecessary_const
178 | - unnecessary_getters_setters
179 | # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
180 | - unnecessary_new
181 | - unnecessary_null_aware_assignments
182 | - unnecessary_null_in_if_null_operators
183 | - unnecessary_overrides
184 | - unnecessary_parenthesis
185 | - unnecessary_statements
186 | - unnecessary_string_interpolations
187 | - unnecessary_this
188 | - unrelated_type_equality_checks
189 | # - unsafe_html # not yet tested
190 | - use_full_hex_values_for_flutter_colors
191 | # - use_function_type_syntax_for_parameters # not yet tested
192 | - use_rethrow_when_possible
193 | # - use_setters_to_change_properties # not yet tested
194 | # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
195 | # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
196 | - valid_regexps
197 | - void_checks
198 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 | applicationId "com.example.flutter_ddd"
42 | minSdkVersion 16
43 | targetSdkVersion 28
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
62 | dependencies {
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64 | testImplementation 'junit:junit:4.12'
65 | androidTestImplementation 'androidx.test:runner:1.1.1'
66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
67 | }
68 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/example/flutter_ddd/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.flutter_ddd
2 |
3 | import androidx.annotation.NonNull;
4 | import io.flutter.embedding.android.FlutterActivity
5 | import io.flutter.embedding.engine.FlutterEngine
6 | import io.flutter.plugins.GeneratedPluginRegistrant
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
10 | GeneratedPluginRegistrant.registerWith(flutterEngine);
11 | }
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/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/doc/images/screencast.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/doc/images/screencast.gif
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def parse_KV_file(file, separator='=')
14 | file_abs_path = File.expand_path(file)
15 | if !File.exists? file_abs_path
16 | return [];
17 | end
18 | generated_key_values = {}
19 | skip_line_start_symbols = ["#", "/"]
20 | File.foreach(file_abs_path) do |line|
21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22 | plugin = line.split(pattern=separator)
23 | if plugin.length == 2
24 | podname = plugin[0].strip()
25 | path = plugin[1].strip()
26 | podpath = File.expand_path("#{path}", file_abs_path)
27 | generated_key_values[podname] = podpath
28 | else
29 | puts "Invalid plugin specification: #{line}"
30 | end
31 | end
32 | generated_key_values
33 | end
34 |
35 | target 'Runner' do
36 | use_frameworks!
37 | use_modular_headers!
38 |
39 | # Flutter Pod
40 |
41 | copied_flutter_dir = File.join(__dir__, 'Flutter')
42 | copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
43 | copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
44 | unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
45 | # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46 | # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47 | # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
48 |
49 | generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
50 | unless File.exist?(generated_xcode_build_settings_path)
51 | raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
52 | end
53 | generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
54 | cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
55 |
56 | unless File.exist?(copied_framework_path)
57 | FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
58 | end
59 | unless File.exist?(copied_podspec_path)
60 | FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
61 | end
62 | end
63 |
64 | # Keep pod path relative so it can be checked into Podfile.lock.
65 | pod 'Flutter', :path => 'Flutter'
66 |
67 | # Plugin Pods
68 |
69 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70 | # referring to absolute paths on developers' machines.
71 | system('rm -rf .symlinks')
72 | system('mkdir -p .symlinks/plugins')
73 | plugin_pods = parse_KV_file('../.flutter-plugins')
74 | plugin_pods.each do |name, path|
75 | symlink = File.join('.symlinks', 'plugins', name)
76 | File.symlink(path, symlink)
77 | pod name, :path => File.join(symlink, 'ios')
78 | end
79 | end
80 |
81 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
82 | install! 'cocoapods', :disable_input_output_paths => true
83 |
84 | post_install do |installer|
85 | installer.pods_project.targets.each do |target|
86 | target.build_configurations.each do |config|
87 | config.build_settings['ENABLE_BITCODE'] = 'NO'
88 | end
89 | end
90 | end
91 |
--------------------------------------------------------------------------------
/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Flutter (1.0.0)
3 | - FMDB (2.7.5):
4 | - FMDB/standard (= 2.7.5)
5 | - FMDB/standard (2.7.5)
6 | - sqflite (0.0.1):
7 | - Flutter
8 | - FMDB (~> 2.7.2)
9 |
10 | DEPENDENCIES:
11 | - Flutter (from `Flutter`)
12 | - sqflite (from `.symlinks/plugins/sqflite/ios`)
13 |
14 | SPEC REPOS:
15 | trunk:
16 | - FMDB
17 |
18 | EXTERNAL SOURCES:
19 | Flutter:
20 | :path: Flutter
21 | sqflite:
22 | :path: ".symlinks/plugins/sqflite/ios"
23 |
24 | SPEC CHECKSUMS:
25 | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
26 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
27 | sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
28 |
29 | PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83
30 |
31 | COCOAPODS: 1.8.4
32 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
17 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
18 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
19 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
20 | E94F384E0C8181E3CBE740FD /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5B30D04642DC0EE341D8697 /* Pods_Runner.framework */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXCopyFilesBuildPhase section */
24 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
25 | isa = PBXCopyFilesBuildPhase;
26 | buildActionMask = 2147483647;
27 | dstPath = "";
28 | dstSubfolderSpec = 10;
29 | files = (
30 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
31 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
32 | );
33 | name = "Embed Frameworks";
34 | runOnlyForDeploymentPostprocessing = 0;
35 | };
36 | /* End PBXCopyFilesBuildPhase section */
37 |
38 | /* Begin PBXFileReference section */
39 | 017677CBFFC0DF64BE009F9B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
40 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
41 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
42 | 3010C5F6B3F3AC2924A98106 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
43 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
44 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
45 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
46 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
47 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
48 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
49 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
50 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
51 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
52 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
53 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
54 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
55 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
56 | AD4AEDB3BFDA18100D51DF98 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
57 | B5B30D04642DC0EE341D8697 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
58 | /* End PBXFileReference section */
59 |
60 | /* Begin PBXFrameworksBuildPhase section */
61 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
62 | isa = PBXFrameworksBuildPhase;
63 | buildActionMask = 2147483647;
64 | files = (
65 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
66 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
67 | E94F384E0C8181E3CBE740FD /* Pods_Runner.framework in Frameworks */,
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | /* End PBXFrameworksBuildPhase section */
72 |
73 | /* Begin PBXGroup section */
74 | 5EC8372A53C6936529C4EF44 /* Frameworks */ = {
75 | isa = PBXGroup;
76 | children = (
77 | B5B30D04642DC0EE341D8697 /* Pods_Runner.framework */,
78 | );
79 | name = Frameworks;
80 | sourceTree = "";
81 | };
82 | 7B04C0A2AB6C212C9D193A02 /* Pods */ = {
83 | isa = PBXGroup;
84 | children = (
85 | AD4AEDB3BFDA18100D51DF98 /* Pods-Runner.debug.xcconfig */,
86 | 017677CBFFC0DF64BE009F9B /* Pods-Runner.release.xcconfig */,
87 | 3010C5F6B3F3AC2924A98106 /* Pods-Runner.profile.xcconfig */,
88 | );
89 | name = Pods;
90 | path = Pods;
91 | sourceTree = "";
92 | };
93 | 9740EEB11CF90186004384FC /* Flutter */ = {
94 | isa = PBXGroup;
95 | children = (
96 | 3B80C3931E831B6300D905FE /* App.framework */,
97 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
98 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
99 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
100 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
101 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
102 | );
103 | name = Flutter;
104 | sourceTree = "";
105 | };
106 | 97C146E51CF9000F007C117D = {
107 | isa = PBXGroup;
108 | children = (
109 | 9740EEB11CF90186004384FC /* Flutter */,
110 | 97C146F01CF9000F007C117D /* Runner */,
111 | 97C146EF1CF9000F007C117D /* Products */,
112 | 7B04C0A2AB6C212C9D193A02 /* Pods */,
113 | 5EC8372A53C6936529C4EF44 /* Frameworks */,
114 | );
115 | sourceTree = "";
116 | };
117 | 97C146EF1CF9000F007C117D /* Products */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 97C146EE1CF9000F007C117D /* Runner.app */,
121 | );
122 | name = Products;
123 | sourceTree = "";
124 | };
125 | 97C146F01CF9000F007C117D /* Runner */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
129 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
130 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
131 | 97C147021CF9000F007C117D /* Info.plist */,
132 | 97C146F11CF9000F007C117D /* Supporting Files */,
133 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
134 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
135 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
136 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
137 | );
138 | path = Runner;
139 | sourceTree = "";
140 | };
141 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
142 | isa = PBXGroup;
143 | children = (
144 | );
145 | name = "Supporting Files";
146 | sourceTree = "";
147 | };
148 | /* End PBXGroup section */
149 |
150 | /* Begin PBXNativeTarget section */
151 | 97C146ED1CF9000F007C117D /* Runner */ = {
152 | isa = PBXNativeTarget;
153 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
154 | buildPhases = (
155 | 4D29CFA8552FB5F7C48E6CAB /* [CP] Check Pods Manifest.lock */,
156 | 9740EEB61CF901F6004384FC /* Run Script */,
157 | 97C146EA1CF9000F007C117D /* Sources */,
158 | 97C146EB1CF9000F007C117D /* Frameworks */,
159 | 97C146EC1CF9000F007C117D /* Resources */,
160 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
161 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
162 | 3439E1E8FB3E87C6F1685FC5 /* [CP] Embed Pods Frameworks */,
163 | );
164 | buildRules = (
165 | );
166 | dependencies = (
167 | );
168 | name = Runner;
169 | productName = Runner;
170 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
171 | productType = "com.apple.product-type.application";
172 | };
173 | /* End PBXNativeTarget section */
174 |
175 | /* Begin PBXProject section */
176 | 97C146E61CF9000F007C117D /* Project object */ = {
177 | isa = PBXProject;
178 | attributes = {
179 | LastUpgradeCheck = 1020;
180 | ORGANIZATIONNAME = "The Chromium Authors";
181 | TargetAttributes = {
182 | 97C146ED1CF9000F007C117D = {
183 | CreatedOnToolsVersion = 7.3.1;
184 | LastSwiftMigration = 1100;
185 | };
186 | };
187 | };
188 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
189 | compatibilityVersion = "Xcode 3.2";
190 | developmentRegion = en;
191 | hasScannedForEncodings = 0;
192 | knownRegions = (
193 | en,
194 | Base,
195 | );
196 | mainGroup = 97C146E51CF9000F007C117D;
197 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
198 | projectDirPath = "";
199 | projectRoot = "";
200 | targets = (
201 | 97C146ED1CF9000F007C117D /* Runner */,
202 | );
203 | };
204 | /* End PBXProject section */
205 |
206 | /* Begin PBXResourcesBuildPhase section */
207 | 97C146EC1CF9000F007C117D /* Resources */ = {
208 | isa = PBXResourcesBuildPhase;
209 | buildActionMask = 2147483647;
210 | files = (
211 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
212 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
213 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
214 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | };
218 | /* End PBXResourcesBuildPhase section */
219 |
220 | /* Begin PBXShellScriptBuildPhase section */
221 | 3439E1E8FB3E87C6F1685FC5 /* [CP] Embed Pods Frameworks */ = {
222 | isa = PBXShellScriptBuildPhase;
223 | buildActionMask = 2147483647;
224 | files = (
225 | );
226 | inputPaths = (
227 | );
228 | name = "[CP] Embed Pods Frameworks";
229 | outputPaths = (
230 | );
231 | runOnlyForDeploymentPostprocessing = 0;
232 | shellPath = /bin/sh;
233 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
234 | showEnvVarsInLog = 0;
235 | };
236 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
237 | isa = PBXShellScriptBuildPhase;
238 | buildActionMask = 2147483647;
239 | files = (
240 | );
241 | inputPaths = (
242 | );
243 | name = "Thin Binary";
244 | outputPaths = (
245 | );
246 | runOnlyForDeploymentPostprocessing = 0;
247 | shellPath = /bin/sh;
248 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
249 | };
250 | 4D29CFA8552FB5F7C48E6CAB /* [CP] Check Pods Manifest.lock */ = {
251 | isa = PBXShellScriptBuildPhase;
252 | buildActionMask = 2147483647;
253 | files = (
254 | );
255 | inputFileListPaths = (
256 | );
257 | inputPaths = (
258 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
259 | "${PODS_ROOT}/Manifest.lock",
260 | );
261 | name = "[CP] Check Pods Manifest.lock";
262 | outputFileListPaths = (
263 | );
264 | outputPaths = (
265 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
266 | );
267 | runOnlyForDeploymentPostprocessing = 0;
268 | shellPath = /bin/sh;
269 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
270 | showEnvVarsInLog = 0;
271 | };
272 | 9740EEB61CF901F6004384FC /* Run Script */ = {
273 | isa = PBXShellScriptBuildPhase;
274 | buildActionMask = 2147483647;
275 | files = (
276 | );
277 | inputPaths = (
278 | );
279 | name = "Run Script";
280 | outputPaths = (
281 | );
282 | runOnlyForDeploymentPostprocessing = 0;
283 | shellPath = /bin/sh;
284 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
285 | };
286 | /* End PBXShellScriptBuildPhase section */
287 |
288 | /* Begin PBXSourcesBuildPhase section */
289 | 97C146EA1CF9000F007C117D /* Sources */ = {
290 | isa = PBXSourcesBuildPhase;
291 | buildActionMask = 2147483647;
292 | files = (
293 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
294 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
295 | );
296 | runOnlyForDeploymentPostprocessing = 0;
297 | };
298 | /* End PBXSourcesBuildPhase section */
299 |
300 | /* Begin PBXVariantGroup section */
301 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
302 | isa = PBXVariantGroup;
303 | children = (
304 | 97C146FB1CF9000F007C117D /* Base */,
305 | );
306 | name = Main.storyboard;
307 | sourceTree = "";
308 | };
309 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
310 | isa = PBXVariantGroup;
311 | children = (
312 | 97C147001CF9000F007C117D /* Base */,
313 | );
314 | name = LaunchScreen.storyboard;
315 | sourceTree = "";
316 | };
317 | /* End PBXVariantGroup section */
318 |
319 | /* Begin XCBuildConfiguration section */
320 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
321 | isa = XCBuildConfiguration;
322 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
323 | buildSettings = {
324 | ALWAYS_SEARCH_USER_PATHS = NO;
325 | CLANG_ANALYZER_NONNULL = YES;
326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
327 | CLANG_CXX_LIBRARY = "libc++";
328 | CLANG_ENABLE_MODULES = YES;
329 | CLANG_ENABLE_OBJC_ARC = YES;
330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
331 | CLANG_WARN_BOOL_CONVERSION = YES;
332 | CLANG_WARN_COMMA = YES;
333 | CLANG_WARN_CONSTANT_CONVERSION = YES;
334 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
336 | CLANG_WARN_EMPTY_BODY = YES;
337 | CLANG_WARN_ENUM_CONVERSION = YES;
338 | CLANG_WARN_INFINITE_RECURSION = YES;
339 | CLANG_WARN_INT_CONVERSION = YES;
340 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
341 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
342 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
344 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
345 | CLANG_WARN_STRICT_PROTOTYPES = YES;
346 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
347 | CLANG_WARN_UNREACHABLE_CODE = YES;
348 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
349 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
350 | COPY_PHASE_STRIP = NO;
351 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
352 | ENABLE_NS_ASSERTIONS = NO;
353 | ENABLE_STRICT_OBJC_MSGSEND = YES;
354 | GCC_C_LANGUAGE_STANDARD = gnu99;
355 | GCC_NO_COMMON_BLOCKS = YES;
356 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
357 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
358 | GCC_WARN_UNDECLARED_SELECTOR = YES;
359 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
360 | GCC_WARN_UNUSED_FUNCTION = YES;
361 | GCC_WARN_UNUSED_VARIABLE = YES;
362 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
363 | MTL_ENABLE_DEBUG_INFO = NO;
364 | SDKROOT = iphoneos;
365 | SUPPORTED_PLATFORMS = iphoneos;
366 | TARGETED_DEVICE_FAMILY = "1,2";
367 | VALIDATE_PRODUCT = YES;
368 | };
369 | name = Profile;
370 | };
371 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
372 | isa = XCBuildConfiguration;
373 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
374 | buildSettings = {
375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
376 | CLANG_ENABLE_MODULES = YES;
377 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
378 | ENABLE_BITCODE = NO;
379 | FRAMEWORK_SEARCH_PATHS = (
380 | "$(inherited)",
381 | "$(PROJECT_DIR)/Flutter",
382 | );
383 | INFOPLIST_FILE = Runner/Info.plist;
384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
385 | LIBRARY_SEARCH_PATHS = (
386 | "$(inherited)",
387 | "$(PROJECT_DIR)/Flutter",
388 | );
389 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterDdd;
390 | PRODUCT_NAME = "$(TARGET_NAME)";
391 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
392 | SWIFT_VERSION = 5.0;
393 | VERSIONING_SYSTEM = "apple-generic";
394 | };
395 | name = Profile;
396 | };
397 | 97C147031CF9000F007C117D /* Debug */ = {
398 | isa = XCBuildConfiguration;
399 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
400 | buildSettings = {
401 | ALWAYS_SEARCH_USER_PATHS = NO;
402 | CLANG_ANALYZER_NONNULL = YES;
403 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
404 | CLANG_CXX_LIBRARY = "libc++";
405 | CLANG_ENABLE_MODULES = YES;
406 | CLANG_ENABLE_OBJC_ARC = YES;
407 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
408 | CLANG_WARN_BOOL_CONVERSION = YES;
409 | CLANG_WARN_COMMA = YES;
410 | CLANG_WARN_CONSTANT_CONVERSION = YES;
411 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
412 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
413 | CLANG_WARN_EMPTY_BODY = YES;
414 | CLANG_WARN_ENUM_CONVERSION = YES;
415 | CLANG_WARN_INFINITE_RECURSION = YES;
416 | CLANG_WARN_INT_CONVERSION = YES;
417 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
418 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
419 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
421 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
422 | CLANG_WARN_STRICT_PROTOTYPES = YES;
423 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
424 | CLANG_WARN_UNREACHABLE_CODE = YES;
425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
426 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
427 | COPY_PHASE_STRIP = NO;
428 | DEBUG_INFORMATION_FORMAT = dwarf;
429 | ENABLE_STRICT_OBJC_MSGSEND = YES;
430 | ENABLE_TESTABILITY = YES;
431 | GCC_C_LANGUAGE_STANDARD = gnu99;
432 | GCC_DYNAMIC_NO_PIC = NO;
433 | GCC_NO_COMMON_BLOCKS = YES;
434 | GCC_OPTIMIZATION_LEVEL = 0;
435 | GCC_PREPROCESSOR_DEFINITIONS = (
436 | "DEBUG=1",
437 | "$(inherited)",
438 | );
439 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
440 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
441 | GCC_WARN_UNDECLARED_SELECTOR = YES;
442 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
443 | GCC_WARN_UNUSED_FUNCTION = YES;
444 | GCC_WARN_UNUSED_VARIABLE = YES;
445 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
446 | MTL_ENABLE_DEBUG_INFO = YES;
447 | ONLY_ACTIVE_ARCH = YES;
448 | SDKROOT = iphoneos;
449 | TARGETED_DEVICE_FAMILY = "1,2";
450 | };
451 | name = Debug;
452 | };
453 | 97C147041CF9000F007C117D /* Release */ = {
454 | isa = XCBuildConfiguration;
455 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
456 | buildSettings = {
457 | ALWAYS_SEARCH_USER_PATHS = NO;
458 | CLANG_ANALYZER_NONNULL = YES;
459 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
460 | CLANG_CXX_LIBRARY = "libc++";
461 | CLANG_ENABLE_MODULES = YES;
462 | CLANG_ENABLE_OBJC_ARC = YES;
463 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
464 | CLANG_WARN_BOOL_CONVERSION = YES;
465 | CLANG_WARN_COMMA = YES;
466 | CLANG_WARN_CONSTANT_CONVERSION = YES;
467 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
468 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
469 | CLANG_WARN_EMPTY_BODY = YES;
470 | CLANG_WARN_ENUM_CONVERSION = YES;
471 | CLANG_WARN_INFINITE_RECURSION = YES;
472 | CLANG_WARN_INT_CONVERSION = YES;
473 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
474 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
475 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
476 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
477 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
478 | CLANG_WARN_STRICT_PROTOTYPES = YES;
479 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
480 | CLANG_WARN_UNREACHABLE_CODE = YES;
481 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
482 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
483 | COPY_PHASE_STRIP = NO;
484 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
485 | ENABLE_NS_ASSERTIONS = NO;
486 | ENABLE_STRICT_OBJC_MSGSEND = YES;
487 | GCC_C_LANGUAGE_STANDARD = gnu99;
488 | GCC_NO_COMMON_BLOCKS = YES;
489 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
490 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
491 | GCC_WARN_UNDECLARED_SELECTOR = YES;
492 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
493 | GCC_WARN_UNUSED_FUNCTION = YES;
494 | GCC_WARN_UNUSED_VARIABLE = YES;
495 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
496 | MTL_ENABLE_DEBUG_INFO = NO;
497 | SDKROOT = iphoneos;
498 | SUPPORTED_PLATFORMS = iphoneos;
499 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
500 | TARGETED_DEVICE_FAMILY = "1,2";
501 | VALIDATE_PRODUCT = YES;
502 | };
503 | name = Release;
504 | };
505 | 97C147061CF9000F007C117D /* Debug */ = {
506 | isa = XCBuildConfiguration;
507 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
508 | buildSettings = {
509 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
510 | CLANG_ENABLE_MODULES = YES;
511 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
512 | ENABLE_BITCODE = NO;
513 | FRAMEWORK_SEARCH_PATHS = (
514 | "$(inherited)",
515 | "$(PROJECT_DIR)/Flutter",
516 | );
517 | INFOPLIST_FILE = Runner/Info.plist;
518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
519 | LIBRARY_SEARCH_PATHS = (
520 | "$(inherited)",
521 | "$(PROJECT_DIR)/Flutter",
522 | );
523 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterDdd;
524 | PRODUCT_NAME = "$(TARGET_NAME)";
525 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
526 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
527 | SWIFT_VERSION = 5.0;
528 | VERSIONING_SYSTEM = "apple-generic";
529 | };
530 | name = Debug;
531 | };
532 | 97C147071CF9000F007C117D /* Release */ = {
533 | isa = XCBuildConfiguration;
534 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
535 | buildSettings = {
536 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
537 | CLANG_ENABLE_MODULES = YES;
538 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
539 | ENABLE_BITCODE = NO;
540 | FRAMEWORK_SEARCH_PATHS = (
541 | "$(inherited)",
542 | "$(PROJECT_DIR)/Flutter",
543 | );
544 | INFOPLIST_FILE = Runner/Info.plist;
545 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
546 | LIBRARY_SEARCH_PATHS = (
547 | "$(inherited)",
548 | "$(PROJECT_DIR)/Flutter",
549 | );
550 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterDdd;
551 | PRODUCT_NAME = "$(TARGET_NAME)";
552 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
553 | SWIFT_VERSION = 5.0;
554 | VERSIONING_SYSTEM = "apple-generic";
555 | };
556 | name = Release;
557 | };
558 | /* End XCBuildConfiguration section */
559 |
560 | /* Begin XCConfigurationList section */
561 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
562 | isa = XCConfigurationList;
563 | buildConfigurations = (
564 | 97C147031CF9000F007C117D /* Debug */,
565 | 97C147041CF9000F007C117D /* Release */,
566 | 249021D3217E4FDB00AE95B9 /* Profile */,
567 | );
568 | defaultConfigurationIsVisible = 0;
569 | defaultConfigurationName = Release;
570 | };
571 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
572 | isa = XCConfigurationList;
573 | buildConfigurations = (
574 | 97C147061CF9000F007C117D /* Debug */,
575 | 97C147071CF9000F007C117D /* Release */,
576 | 249021D4217E4FDB00AE95B9 /* Profile */,
577 | );
578 | defaultConfigurationIsVisible = 0;
579 | defaultConfigurationName = Release;
580 | };
581 | /* End XCConfigurationList section */
582 | };
583 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
584 | }
585 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
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/100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/100.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/1024.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/114.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/120.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/144.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/152.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/167.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/180.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/20.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/29.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/40.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/50.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/57.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/58.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/60.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/72.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/76.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/80.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/AppIcon.appiconset/87.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"72x72","expected-size":"72","filename":"72.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"76x76","expected-size":"152","filename":"152.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"50x50","expected-size":"100","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"76x76","expected-size":"76","filename":"76.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"50x50","expected-size":"50","filename":"50.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"72x72","expected-size":"144","filename":"144.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"40x40","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"83.5x83.5","expected-size":"167","filename":"167.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"20x20","expected-size":"20","filename":"20.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"}]}
--------------------------------------------------------------------------------
/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/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaboc/flutter_ddd/b4d223a824e0eff8e9dbf23469b61ad05d62e59d/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | Notes
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
--------------------------------------------------------------------------------
/lib/application/category_app_service.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 | import 'package:flutter_ddd/domain/category/category_factory_base.dart';
4 | import 'package:flutter_ddd/domain/category/category_repository_base.dart';
5 | import 'package:flutter_ddd/domain/category/category_service.dart';
6 | import 'package:flutter_ddd/domain/note/note_repository_base.dart';
7 | import 'package:flutter_ddd/application/dto/category_dto.dart';
8 |
9 | export 'package:flutter_ddd/application/dto/category_dto.dart';
10 |
11 | @immutable
12 | class CategoryAppService {
13 | final CategoryFactoryBase _factory;
14 | final CategoryRepositoryBase _repository;
15 | final NoteRepositoryBase _noteRepository;
16 | final CategoryService _service;
17 |
18 | CategoryAppService({
19 | @required CategoryFactoryBase factory,
20 | @required CategoryRepositoryBase repository,
21 | @required NoteRepositoryBase noteRepository,
22 | }) : _factory = factory,
23 | _repository = repository,
24 | _noteRepository = noteRepository,
25 | _service = CategoryService(repository: repository);
26 |
27 | Future saveCategory({@required String name}) async {
28 | final category = _factory.create(name: name);
29 |
30 | await _repository.transaction(() async {
31 | if (await _service.isDuplicated(category.name)) {
32 | throw NotUniqueException(
33 | code: ExceptionCode.categoryName,
34 | value: category.name.value,
35 | );
36 | } else {
37 | await _repository.save(category);
38 | }
39 | });
40 | }
41 |
42 | Future updateCategory({
43 | @required String id,
44 | @required String name,
45 | }) async {
46 | final targetId = CategoryId(id);
47 |
48 | await _repository.transaction(() async {
49 | final target = await _repository.find(targetId);
50 | if (target == null) {
51 | throw NotFoundException(
52 | code: ExceptionCode.categoryId,
53 | target: targetId.value,
54 | );
55 | }
56 |
57 | final newName = CategoryName(name);
58 | if (newName != target.name && await _service.isDuplicated(newName)) {
59 | throw NotUniqueException(
60 | code: ExceptionCode.categoryName,
61 | value: newName.value,
62 | );
63 | }
64 | target.changeName(newName);
65 |
66 | await _repository.save(target);
67 | });
68 | }
69 |
70 | Future removeCategory(String id) async {
71 | final targetId = CategoryId(id);
72 |
73 | await _repository.transaction(() async {
74 | final target = await _repository.find(targetId);
75 | if (target == null) {
76 | throw NotFoundException(
77 | code: ExceptionCode.categoryId,
78 | target: targetId.value,
79 | );
80 | }
81 |
82 | if (await _noteRepository.countByCategory(targetId) > 0) {
83 | throw RemovalException(code: ExceptionCode.category);
84 | }
85 |
86 | await _repository.remove(target);
87 | });
88 | }
89 |
90 | Future> getCategoryList() async {
91 | final categories = await _repository.findAll();
92 | return categories.map((x) => CategoryDto(x)).toList();
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/lib/application/dto/category_dto.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 |
3 | import 'package:flutter_ddd/domain/category/category.dart';
4 |
5 | @immutable
6 | class CategoryDto {
7 | final String id;
8 | final String name;
9 |
10 | CategoryDto(Category source)
11 | : id = source.id.value,
12 | name = source.name.value;
13 | }
14 |
--------------------------------------------------------------------------------
/lib/application/dto/note_dto.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 |
3 | import 'package:flutter_ddd/domain/note/note.dart';
4 |
5 | @immutable
6 | class NoteDto {
7 | final String id;
8 | final String title;
9 | final String body;
10 | final String categoryId;
11 |
12 | NoteDto(Note source)
13 | : id = source.id.value,
14 | title = source.title.value,
15 | body = source.body.value,
16 | categoryId = source.categoryId.value;
17 | }
18 |
--------------------------------------------------------------------------------
/lib/application/dto/note_summary_dto.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 |
3 | import 'package:flutter_ddd/domain/note/note.dart';
4 |
5 | @immutable
6 | class NoteSummaryDto {
7 | final String id;
8 | final String title;
9 |
10 | NoteSummaryDto(Note source)
11 | : id = source.id.value,
12 | title = source.title.value;
13 | }
14 |
--------------------------------------------------------------------------------
/lib/application/note_app_service.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 | import 'package:flutter_ddd/domain/note/note_factory_base.dart';
4 | import 'package:flutter_ddd/domain/note/note_service.dart';
5 | import 'package:flutter_ddd/application/dto/note_dto.dart';
6 | import 'package:flutter_ddd/application/dto/note_summary_dto.dart';
7 | import 'package:flutter_ddd/domain/note/note_repository_base.dart';
8 |
9 | export 'package:flutter_ddd/application/dto/note_dto.dart';
10 | export 'package:flutter_ddd/application/dto/note_summary_dto.dart';
11 |
12 | @immutable
13 | class NoteAppService {
14 | final NoteFactoryBase _factory;
15 | final NoteRepositoryBase _repository;
16 | final NoteService _service;
17 |
18 | NoteAppService({
19 | @required NoteFactoryBase factory,
20 | @required NoteRepositoryBase repository,
21 | }) : _factory = factory,
22 | _repository = repository,
23 | _service = NoteService(repository: repository);
24 |
25 | Future saveNote({
26 | @required String title,
27 | @required String body,
28 | @required String categoryId,
29 | }) async {
30 | final note = _factory.create(
31 | title: NoteTitle(title),
32 | body: NoteBody(body),
33 | categoryId: CategoryId(categoryId),
34 | );
35 |
36 | await _repository.transaction(() async {
37 | if (await _service.isDuplicated(note.title)) {
38 | throw NotUniqueException(
39 | code: ExceptionCode.noteTitle,
40 | value: note.title.value,
41 | );
42 | } else {
43 | await _repository.save(note);
44 | }
45 | });
46 | }
47 |
48 | Future updateNote({
49 | @required String id,
50 | @required String title,
51 | @required String body,
52 | @required String categoryId,
53 | }) async {
54 | final targetId = NoteId(id);
55 |
56 | await _repository.transaction(() async {
57 | final target = await _repository.find(targetId);
58 | if (target == null) {
59 | throw NotFoundException(
60 | code: ExceptionCode.noteId,
61 | target: targetId.value,
62 | );
63 | }
64 |
65 | final newTitle = NoteTitle(title);
66 | if (newTitle != target.title && await _service.isDuplicated(newTitle)) {
67 | throw NotUniqueException(
68 | code: ExceptionCode.noteTitle,
69 | value: newTitle.value,
70 | );
71 | }
72 | target.changeTitle(newTitle);
73 |
74 | final newBody = NoteBody(body);
75 | target.changeBody(newBody);
76 |
77 | final newCategoryId = CategoryId(categoryId);
78 | target.changeCategory(newCategoryId);
79 |
80 | await _repository.save(target);
81 | });
82 | }
83 |
84 | Future removeNote(String id) async {
85 | final targetId = NoteId(id);
86 |
87 | await _repository.transaction(() async {
88 | final target = await _repository.find(targetId);
89 | if (target == null) {
90 | throw NotFoundException(
91 | code: ExceptionCode.noteId,
92 | target: targetId.value,
93 | );
94 | }
95 |
96 | await _repository.remove(target);
97 | });
98 | }
99 |
100 | Future getNote(String id) async {
101 | final targetId = NoteId(id);
102 | final target = await _repository.find(targetId);
103 |
104 | return target == null ? null : NoteDto(target);
105 | }
106 |
107 | Future> getNoteList(String categoryId) async {
108 | final targetId = CategoryId(categoryId);
109 | final notes = await _repository.findByCategory(targetId);
110 |
111 | return notes.map((x) => NoteSummaryDto(x)).toList();
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/lib/common/exception.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 |
3 | class GenericException implements Exception {
4 | final ExceptionCode code;
5 | final dynamic info;
6 |
7 | GenericException({this.code = ExceptionCode.unknown, this.info});
8 |
9 | @override
10 | String toString() {
11 | return '$runtimeType: ${code.value}';
12 | }
13 |
14 | String get message {
15 | switch (runtimeType) {
16 | case NotFoundException:
17 | return '${code.value}: $info\nis not found.';
18 | case NotUniqueException:
19 | return '${code.value}: $info\nalready exists.';
20 | case NullEmptyException:
21 | return '${code.value}\nmust not be null or empty.';
22 | case LengthException:
23 | return '${code.value} must be $info letters or shorter.';
24 | case RemovalException:
25 | return code == ExceptionCode.category
26 | ? 'Cannot be removed;\nthis category contains notes.'
27 | : 'Cannot be removed';
28 | default:
29 | return 'Unknown error occurred.';
30 | }
31 | }
32 | }
33 |
34 | class NotFoundException extends GenericException {
35 | NotFoundException({@required ExceptionCode code, @required String target})
36 | : assert(code != null),
37 | assert(target != null && target.isNotEmpty),
38 | super(code: code, info: target);
39 | }
40 |
41 | class NotUniqueException extends GenericException {
42 | NotUniqueException({@required ExceptionCode code, @required String value})
43 | : assert(code != null),
44 | assert(value != null && value.isNotEmpty),
45 | super(code: code, info: value);
46 | }
47 |
48 | class NullEmptyException extends GenericException {
49 | NullEmptyException({@required ExceptionCode code})
50 | : assert(code != null),
51 | super(code: code);
52 | }
53 |
54 | class LengthException extends GenericException {
55 | LengthException({@required ExceptionCode code, @required int max})
56 | : assert(code != null),
57 | assert(max != null && max > 0),
58 | super(code: code, info: max);
59 | }
60 |
61 | class RemovalException extends GenericException {
62 | RemovalException({@required ExceptionCode code})
63 | : assert(code != null),
64 | super(code: code);
65 | }
66 |
67 | enum ExceptionCode {
68 | unknown,
69 | category,
70 | categoryId,
71 | categoryName,
72 | note,
73 | noteId,
74 | noteTitle,
75 | }
76 |
77 | extension ExceptionCodeValue on ExceptionCode {
78 | String get value {
79 | switch (this) {
80 | case ExceptionCode.category:
81 | return 'Category';
82 | case ExceptionCode.categoryId:
83 | return 'Category ID';
84 | case ExceptionCode.categoryName:
85 | return 'Category name';
86 | case ExceptionCode.note:
87 | return 'Note';
88 | case ExceptionCode.noteId:
89 | return 'Note ID';
90 | case ExceptionCode.noteTitle:
91 | return 'Note title';
92 | default:
93 | return 'Unknown';
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/lib/domain/category/category.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/category/value/category_id.dart';
3 | import 'package:flutter_ddd/domain/category/value/category_name.dart';
4 |
5 | export 'package:flutter_ddd/domain/category/value/category_id.dart';
6 | export 'package:flutter_ddd/domain/category/value/category_name.dart';
7 |
8 | class Category {
9 | final CategoryId id;
10 | CategoryName _name;
11 |
12 | Category({@required this.id, @required CategoryName name}) : _name = name;
13 |
14 | CategoryName get name => _name;
15 |
16 | @override
17 | // ignore: avoid_equals_and_hash_code_on_mutable_classes
18 | bool operator ==(Object other) =>
19 | identical(other, this) || (other is Category && other.id == id);
20 |
21 | @override
22 | // ignore: avoid_equals_and_hash_code_on_mutable_classes
23 | int get hashCode => runtimeType.hashCode ^ id.hashCode;
24 |
25 | void changeName(CategoryName newName) {
26 | _name = newName;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/domain/category/category_factory_base.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/category/category.dart';
3 |
4 | export 'package:flutter_ddd/domain/category/category.dart';
5 |
6 | abstract class CategoryFactoryBase {
7 | Category create({@required String name});
8 | }
9 |
--------------------------------------------------------------------------------
/lib/domain/category/category_repository_base.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_ddd/domain/category/category.dart';
2 |
3 | export 'package:flutter_ddd/domain/category/category.dart';
4 |
5 | abstract class CategoryRepositoryBase {
6 | Future transaction(Future Function() f);
7 | Future find(CategoryId id);
8 | Future findByName(CategoryName name);
9 | Future> findAll();
10 | Future save(Category category);
11 | Future remove(Category category);
12 | }
13 |
--------------------------------------------------------------------------------
/lib/domain/category/category_service.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/category/category_repository_base.dart';
3 |
4 | class CategoryService {
5 | final CategoryRepositoryBase _repository;
6 |
7 | const CategoryService({@required CategoryRepositoryBase repository})
8 | : _repository = repository;
9 |
10 | Future isDuplicated(CategoryName name) async {
11 | final searched = await _repository.findByName(name);
12 | return searched != null;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/domain/category/value/category_id.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 |
4 | @immutable
5 | class CategoryId {
6 | final String value;
7 |
8 | CategoryId(this.value) {
9 | if (value == null || value.isEmpty) {
10 | throw NullEmptyException(code: ExceptionCode.categoryId);
11 | }
12 | }
13 |
14 | @override
15 | bool operator ==(Object other) =>
16 | identical(other, this) || (other is CategoryId && other.value == value);
17 |
18 | @override
19 | int get hashCode => runtimeType.hashCode ^ value.hashCode;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/domain/category/value/category_name.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 |
4 | @immutable
5 | class CategoryName {
6 | final String value;
7 |
8 | CategoryName(this.value) {
9 | if (value == null || value.isEmpty) {
10 | throw NullEmptyException(code: ExceptionCode.categoryName);
11 | }
12 | if (value.length > 20) {
13 | throw LengthException(code: ExceptionCode.categoryName, max: 20);
14 | }
15 | }
16 |
17 | @override
18 | bool operator ==(Object other) =>
19 | identical(other, this) || (other is CategoryName && other.value == value);
20 |
21 | @override
22 | int get hashCode => runtimeType.hashCode ^ value.hashCode;
23 | }
24 |
--------------------------------------------------------------------------------
/lib/domain/note/note.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/category/value/category_id.dart';
3 | import 'package:flutter_ddd/domain/note/value/note_body.dart';
4 | import 'package:flutter_ddd/domain/note/value/note_id.dart';
5 | import 'package:flutter_ddd/domain/note/value/note_title.dart';
6 |
7 | export 'package:flutter_ddd/domain/category/value/category_id.dart';
8 | export 'package:flutter_ddd/domain/note/value/note_body.dart';
9 | export 'package:flutter_ddd/domain/note/value/note_id.dart';
10 | export 'package:flutter_ddd/domain/note/value/note_title.dart';
11 |
12 | class Note {
13 | final NoteId id;
14 | NoteTitle _title;
15 | NoteBody _body;
16 | CategoryId _categoryId;
17 |
18 | Note({
19 | @required this.id,
20 | @required NoteTitle title,
21 | @required NoteBody body,
22 | @required CategoryId categoryId,
23 | }) : _title = title,
24 | _body = body,
25 | _categoryId = categoryId;
26 |
27 | NoteTitle get title => _title;
28 | NoteBody get body => _body;
29 | CategoryId get categoryId => _categoryId;
30 |
31 | @override
32 | // ignore: avoid_equals_and_hash_code_on_mutable_classes
33 | bool operator ==(Object other) =>
34 | identical(other, this) || (other is Note && other.id == id);
35 |
36 | @override
37 | // ignore: avoid_equals_and_hash_code_on_mutable_classes
38 | int get hashCode => runtimeType.hashCode ^ id.hashCode;
39 |
40 | void changeTitle(NoteTitle newTitle) {
41 | _title = newTitle;
42 | }
43 |
44 | void changeBody(NoteBody newBody) {
45 | _body = newBody;
46 | }
47 |
48 | void changeCategory(CategoryId newCategoryId) {
49 | _categoryId = newCategoryId;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/lib/domain/note/note_factory_base.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/note/note.dart';
3 |
4 | export 'package:flutter_ddd/domain/note/note.dart';
5 |
6 | abstract class NoteFactoryBase {
7 | Note create({
8 | @required NoteTitle title,
9 | @required NoteBody body,
10 | @required CategoryId categoryId,
11 | });
12 | }
13 |
--------------------------------------------------------------------------------
/lib/domain/note/note_repository_base.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_ddd/domain/note/note.dart';
2 |
3 | export 'package:flutter_ddd/domain/note/note.dart';
4 |
5 | abstract class NoteRepositoryBase {
6 | Future transaction(Future Function() f);
7 | Future find(NoteId id);
8 | Future findByTitle(NoteTitle title);
9 | Future> findByCategory(CategoryId categoryId);
10 | Future countByCategory(CategoryId categoryId);
11 | Future save(Note note);
12 | Future remove(Note note);
13 | }
14 |
--------------------------------------------------------------------------------
/lib/domain/note/note_service.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/note/note_repository_base.dart';
3 |
4 | class NoteService {
5 | final NoteRepositoryBase _repository;
6 |
7 | const NoteService({@required NoteRepositoryBase repository})
8 | : _repository = repository;
9 |
10 | Future isDuplicated(NoteTitle title) async {
11 | final searched = await _repository.findByTitle(title);
12 | return searched != null;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/domain/note/value/note_body.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 |
4 | @immutable
5 | class NoteBody {
6 | final String value;
7 |
8 | NoteBody(this.value) {
9 | if (value == null || value.isEmpty) {
10 | throw NullEmptyException(code: ExceptionCode.note);
11 | }
12 | }
13 |
14 | @override
15 | bool operator ==(Object other) =>
16 | identical(other, this) || (other is NoteBody && other.value == value);
17 |
18 | @override
19 | int get hashCode => runtimeType.hashCode ^ value.hashCode;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/domain/note/value/note_id.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 |
4 | @immutable
5 | class NoteId {
6 | final String value;
7 |
8 | NoteId(this.value) {
9 | if (value == null || value.isEmpty) {
10 | throw NullEmptyException(code: ExceptionCode.noteId);
11 | }
12 | }
13 |
14 | @override
15 | bool operator ==(Object other) =>
16 | identical(other, this) || (other is NoteId && other.value == value);
17 |
18 | @override
19 | int get hashCode => runtimeType.hashCode ^ value.hashCode;
20 | }
21 |
--------------------------------------------------------------------------------
/lib/domain/note/value/note_title.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/common/exception.dart';
3 |
4 | @immutable
5 | class NoteTitle {
6 | final String value;
7 |
8 | NoteTitle(this.value) {
9 | if (value == null || value.isEmpty) {
10 | throw NullEmptyException(code: ExceptionCode.noteTitle);
11 | }
12 | if (value.length > 50) {
13 | throw LengthException(code: ExceptionCode.noteTitle, max: 50);
14 | }
15 | }
16 |
17 | @override
18 | bool operator ==(Object other) =>
19 | identical(other, this) || (other is NoteTitle && other.value == value);
20 |
21 | @override
22 | int get hashCode => runtimeType.hashCode ^ value.hashCode;
23 | }
24 |
--------------------------------------------------------------------------------
/lib/infrastructure/category/category_factory.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:uuid/uuid.dart';
3 | import 'package:flutter_ddd/domain/category/category_factory_base.dart';
4 |
5 | class CategoryFactory implements CategoryFactoryBase {
6 | const CategoryFactory();
7 |
8 | @override
9 | Category create({@required String name}) {
10 | return Category(
11 | id: CategoryId(Uuid().v4()),
12 | name: CategoryName(name),
13 | );
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lib/infrastructure/category/category_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/category/category_repository_base.dart';
3 | import 'package:flutter_ddd/infrastructure/db_helper.dart';
4 |
5 | export 'package:flutter_ddd/domain/category/category_repository_base.dart';
6 |
7 | class CategoryRepository implements CategoryRepositoryBase {
8 | final DbHelper _dbHelper;
9 |
10 | const CategoryRepository({@required DbHelper dbHelper}) : _dbHelper = dbHelper;
11 |
12 | Category toCategory(Map data) {
13 | final id = data['id'].toString();
14 | final name = data['name'].toString();
15 |
16 | return Category(
17 | id: CategoryId(id),
18 | name: CategoryName(name),
19 | );
20 | }
21 |
22 | @override
23 | Future transaction(Future Function() f) async {
24 | return await _dbHelper.transaction(() async => await f());
25 | }
26 |
27 | @override
28 | Future find(CategoryId id) async {
29 | final list = await _dbHelper.rawQuery(
30 | 'SELECT * FROM categories WHERE id = ?',
31 | [id.value],
32 | );
33 |
34 | return list.isEmpty ? null : toCategory(list[0]);
35 | }
36 |
37 | @override
38 | Future findByName(CategoryName name) async {
39 | final list = await _dbHelper.rawQuery(
40 | 'SELECT * FROM categories WHERE name = ?',
41 | [name.value],
42 | );
43 |
44 | return list.isEmpty ? null : toCategory(list[0]);
45 | }
46 |
47 | @override
48 | Future> findAll() async {
49 | final list = await _dbHelper.rawQuery(
50 | 'SELECT * FROM categories ORDER BY name',
51 | );
52 |
53 | if (list.isEmpty) {
54 | return [];
55 | }
56 |
57 | return list.map((data) => toCategory(data)).toList();
58 | }
59 |
60 | @override
61 | Future save(Category category) async {
62 | await _dbHelper.rawInsert(
63 | 'INSERT OR REPLACE INTO categories (id, name) VALUES (?, ?)',
64 | [category.id.value, category.name.value],
65 | );
66 | }
67 |
68 | @override
69 | Future remove(Category category) async {
70 | await _dbHelper.rawDelete(
71 | 'DELETE FROM categories WHERE id = ?',
72 | [category.id.value],
73 | );
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/lib/infrastructure/db_helper.dart:
--------------------------------------------------------------------------------
1 | import 'package:sqflite/sqflite.dart';
2 | import 'package:path/path.dart';
3 |
4 | const _dbFile = 'ddd.db';
5 | const _dbVersion = 1;
6 |
7 | class DbHelper {
8 | Database _db;
9 | Transaction _txn;
10 |
11 | Future open() async {
12 | final databasesPath = await getDatabasesPath();
13 | final path = join(databasesPath, _dbFile);
14 |
15 | _db = await openDatabase(
16 | path,
17 | version: _dbVersion,
18 | onCreate: (Database db, int version) async {
19 | await db.execute('''
20 | CREATE TABLE notes (
21 | id TEXT NOT NULL,
22 | title TEXT NOT NULL,
23 | body TEXT NOT NULL,
24 | category_id TEXT NOT NULL,
25 | PRIMARY KEY (id)
26 | )
27 | ''');
28 |
29 | await db.execute('''
30 | CREATE INDEX idx_category_id
31 | ON notes(category_id)
32 | ''');
33 |
34 | await db.execute('''
35 | CREATE TABLE categories (
36 | id TEXT NOT NULL,
37 | name TEXT NOT NULL,
38 | PRIMARY KEY (id)
39 | )
40 | ''');
41 | },
42 | );
43 |
44 | return _db;
45 | }
46 |
47 | Future dispose() async {
48 | await _db?.close();
49 | _db = null;
50 | }
51 |
52 | Future transaction(Future Function() f) async {
53 | return _db.transaction((txn) async {
54 | _txn = txn;
55 | return await f();
56 | }).then((v) {
57 | _txn = null;
58 | return v;
59 | });
60 | }
61 |
62 | Future>> rawQuery(
63 | String sql, [
64 | List arguments,
65 | ]) async {
66 | return await (_txn ?? _db).rawQuery(sql, arguments);
67 | }
68 |
69 | Future rawInsert(
70 | String sql, [
71 | List arguments,
72 | ]) async {
73 | return await (_txn ?? _db).rawInsert(sql, arguments);
74 | }
75 |
76 | Future rawDelete(
77 | String sql, [
78 | List arguments,
79 | ]) async {
80 | return await (_txn ?? _db).rawDelete(sql, arguments);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/lib/infrastructure/note/note_factory.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:uuid/uuid.dart';
3 | import 'package:flutter_ddd/domain/note/note_factory_base.dart';
4 |
5 | class NoteFactory implements NoteFactoryBase {
6 | const NoteFactory();
7 |
8 | @override
9 | Note create({
10 | @required NoteTitle title,
11 | @required NoteBody body,
12 | @required CategoryId categoryId,
13 | }) {
14 | return Note(
15 | id: NoteId(Uuid().v4()),
16 | title: title,
17 | body: body,
18 | categoryId: categoryId,
19 | );
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/infrastructure/note/note_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:meta/meta.dart';
2 | import 'package:flutter_ddd/domain/note/note_repository_base.dart';
3 | import 'package:flutter_ddd/infrastructure/db_helper.dart';
4 |
5 | export 'package:flutter_ddd/domain/note/note_repository_base.dart';
6 |
7 | class NoteRepository implements NoteRepositoryBase {
8 | final DbHelper _dbHelper;
9 |
10 | const NoteRepository({@required DbHelper dbHelper}) : _dbHelper = dbHelper;
11 |
12 | Note toNote(Map data) {
13 | final id = data['id'].toString();
14 | final title = data['title'].toString();
15 | final body = data['body'].toString();
16 | final categoryId = data['category_id'].toString();
17 |
18 | return Note(
19 | id: NoteId(id),
20 | title: NoteTitle(title),
21 | body: NoteBody(body),
22 | categoryId: categoryId == null || categoryId.isEmpty
23 | ? null
24 | : CategoryId(categoryId),
25 | );
26 | }
27 |
28 | @override
29 | Future transaction(Future Function() f) async {
30 | return await _dbHelper.transaction(() async => await f());
31 | }
32 |
33 | @override
34 | Future find(NoteId id) async {
35 | final list = await _dbHelper.rawQuery(
36 | 'SELECT * FROM notes WHERE id = ?',
37 | [id.value],
38 | );
39 |
40 | return list.isEmpty ? null : toNote(list[0]);
41 | }
42 |
43 | @override
44 | Future findByTitle(NoteTitle title) async {
45 | final list = await _dbHelper.rawQuery(
46 | 'SELECT * FROM notes WHERE title = ?',
47 | [title.value],
48 | );
49 |
50 | return list.isEmpty ? null : toNote(list[0]);
51 | }
52 |
53 | @override
54 | Future> findByCategory(CategoryId categoryId) async {
55 | final list = await _dbHelper.rawQuery(
56 | 'SELECT * FROM notes WHERE category_id = ? ORDER BY title',
57 | [categoryId.value],
58 | );
59 |
60 | if (list.isEmpty) {
61 | return [];
62 | }
63 |
64 | return list.map((data) => toNote(data)).toList();
65 | }
66 |
67 | @override
68 | Future countByCategory(CategoryId categoryId) async {
69 | final list = await _dbHelper.rawQuery(
70 | 'SELECT COUNT(*) AS cnt FROM notes WHERE category_id = ?',
71 | [categoryId.value],
72 | );
73 |
74 | final row = Map.from(list[0]);
75 | return row['cnt'];
76 | }
77 |
78 | @override
79 | Future save(Note note) async {
80 | await _dbHelper.rawInsert(
81 | '''
82 | INSERT OR REPLACE INTO notes
83 | (id, title, body, category_id) VALUES (?, ?, ?, ?)
84 | ''',
85 | [
86 | note.id.value,
87 | note.title.value,
88 | note.body.value,
89 | note.categoryId?.value,
90 | ],
91 | );
92 | }
93 |
94 | @override
95 | Future remove(Note note) async {
96 | await _dbHelper.rawDelete(
97 | 'DELETE FROM notes WHERE id = ?',
98 | [note.id.value],
99 | );
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/lib/init.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_ddd/infrastructure/db_helper.dart';
3 | import 'package:flutter_ddd/presentation/page/category_list.dart';
4 |
5 | class AppInit {
6 | final GlobalKey navigatorKey;
7 |
8 | AppInit({
9 | @required this.navigatorKey,
10 | @required DbHelper dbHelper,
11 | }) {
12 | dbHelper.open().then((_) {
13 | navigatorKey.currentState.pushAndRemoveUntil(
14 | MaterialPageRoute(
15 | builder: (_) => const CategoryListPage(),
16 | ),
17 | (_) => false,
18 | );
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/application/category_app_service.dart';
4 | import 'package:flutter_ddd/infrastructure/category/category_factory.dart';
5 | import 'package:flutter_ddd/infrastructure/category/category_repository.dart';
6 | import 'package:flutter_ddd/infrastructure/db_helper.dart';
7 | import 'package:flutter_ddd/infrastructure/note/note_repository.dart';
8 | import 'package:flutter_ddd/init.dart';
9 | import 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
10 | import 'package:flutter_ddd/presentation/page/init.dart';
11 |
12 | const appTitle = 'Notes';
13 |
14 | void main() => runApp(const MyApp());
15 |
16 | class MyApp extends StatelessWidget {
17 | const MyApp();
18 |
19 | @override
20 | Widget build(BuildContext context) {
21 | return MultiProvider(
22 | providers: [
23 | Provider(
24 | create: (_) => DbHelper(),
25 | dispose: (_, helper) async => await helper.dispose(),
26 | ),
27 | Provider(
28 | create: (context) => CategoryRepository(
29 | dbHelper: context.read(),
30 | ),
31 | ),
32 | Provider(
33 | create: (context) => NoteRepository(
34 | dbHelper: context.read(),
35 | ),
36 | ),
37 | ChangeNotifierProvider(
38 | create: (context) => CategoryNotifier(
39 | app: CategoryAppService(
40 | factory: const CategoryFactory(),
41 | repository: context.read(),
42 | noteRepository: context.read(),
43 | ),
44 | ),
45 | ),
46 | Provider(
47 | create: (context) => AppInit(
48 | navigatorKey: GlobalKey(),
49 | dbHelper: context.read(),
50 | ),
51 | ),
52 | ],
53 | child: const _Init(),
54 | );
55 | }
56 | }
57 |
58 | class _Init extends StatelessWidget {
59 | const _Init();
60 |
61 | @override
62 | Widget build(BuildContext context) {
63 | return MaterialApp(
64 | title: appTitle,
65 | theme: ThemeData(primarySwatch: Colors.green),
66 | navigatorKey: Provider.of(context).navigatorKey,
67 | onGenerateRoute: (_) {
68 | return MaterialPageRoute(
69 | builder: (_) => const InitPage(appTitle: appTitle),
70 | );
71 | },
72 | );
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/lib/presentation/notifier/category_notifier.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 | import 'package:flutter_ddd/application/category_app_service.dart';
3 |
4 | export 'package:flutter_ddd/application/dto/category_dto.dart';
5 |
6 | class CategoryNotifier with ChangeNotifier {
7 | final CategoryAppService _app;
8 |
9 | CategoryNotifier({@required CategoryAppService app}) : _app = app {
10 | _updateList();
11 | }
12 |
13 | List _list;
14 |
15 | List get list => _list == null ? null : List.unmodifiable(_list);
16 |
17 | Future saveCategory({
18 | @required String name,
19 | }) async {
20 | await _app.saveCategory(name: name);
21 | _updateList();
22 | }
23 |
24 | Future updateCategory({
25 | @required String id,
26 | @required String name,
27 | }) async {
28 | await _app.updateCategory(id: id, name: name);
29 | _updateList();
30 | }
31 |
32 | Future removeCategory(String id) async {
33 | await _app.removeCategory(id);
34 | _updateList();
35 | }
36 |
37 | void _updateList() {
38 | _app.getCategoryList().then((list) {
39 | _list = list;
40 | notifyListeners();
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/presentation/notifier/note_notifier.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 | import 'package:flutter_ddd/application/note_app_service.dart';
3 |
4 | export 'package:flutter_ddd/application/dto/note_summary_dto.dart';
5 |
6 | class NoteNotifier with ChangeNotifier {
7 | final NoteAppService _app;
8 | final String _categoryId;
9 |
10 | NoteNotifier({@required NoteAppService app, @required String categoryId})
11 | : _app = app,
12 | _categoryId = categoryId {
13 | _updateList();
14 | }
15 |
16 | List _list;
17 |
18 | List get list =>
19 | _list == null ? null : List.unmodifiable(_list);
20 |
21 | Future saveNote({
22 | @required String title,
23 | @required String body,
24 | @required String categoryId,
25 | }) async {
26 | await _app.saveNote(
27 | title: title,
28 | body: body,
29 | categoryId: categoryId,
30 | );
31 | _updateList();
32 | }
33 |
34 | Future updateNote({
35 | @required String id,
36 | @required String title,
37 | @required String body,
38 | @required String categoryId,
39 | }) async {
40 | await _app.updateNote(
41 | id: id,
42 | title: title,
43 | body: body,
44 | categoryId: categoryId,
45 | );
46 | _updateList();
47 | }
48 |
49 | Future removeNote(String id) async {
50 | await _app.removeNote(id);
51 | _updateList();
52 | }
53 |
54 | Future getNote(String id) async {
55 | return await _app.getNote(id);
56 | }
57 |
58 | void _updateList() {
59 | _app.getNoteList(_categoryId).then((list) {
60 | _list = list;
61 | notifyListeners();
62 | });
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/lib/presentation/page/category_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/presentation/widget/category/add_button.dart';
4 | import 'package:flutter_ddd/presentation/widget/category/category_list_view.dart';
5 |
6 | class CategoryListPage extends StatelessWidget {
7 | const CategoryListPage();
8 |
9 | @override
10 | Widget build(BuildContext context) {
11 | return ChangeNotifierProvider(
12 | create: (_) => TextEditingController(),
13 | child: Scaffold(
14 | appBar: AppBar(title: const Text('Categories')),
15 | body: const CategoryListView(),
16 | floatingActionButton: const CategoryAddButton(),
17 | ),
18 | );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/presentation/page/init.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class InitPage extends StatelessWidget {
4 | final String appTitle;
5 |
6 | const InitPage({@required this.appTitle});
7 |
8 | @override
9 | Widget build(BuildContext context) {
10 | return Scaffold(
11 | backgroundColor: Theme.of(context).accentColor,
12 | body: Center(
13 | child: Text(
14 | appTitle,
15 | style: Theme.of(context).primaryTextTheme.headline6,
16 | ),
17 | ),
18 | );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/presentation/page/note_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/domain/note/note_repository_base.dart';
4 | import 'package:flutter_ddd/presentation/widget/note/edit_dialog.dart';
5 | import 'package:flutter_ddd/application/note_app_service.dart';
6 | import 'package:flutter_ddd/application/dto/category_dto.dart';
7 | import 'package:flutter_ddd/infrastructure/note/note_factory.dart';
8 | import 'package:flutter_ddd/presentation/notifier/note_notifier.dart';
9 | import 'package:flutter_ddd/presentation/widget/note/add_button.dart';
10 | import 'package:flutter_ddd/presentation/widget/note/note_list_view.dart';
11 |
12 | class NoteListPage extends StatelessWidget {
13 | final CategoryDto category;
14 |
15 | const NoteListPage({@required this.category});
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | return MultiProvider(
20 | providers: [
21 | ChangeNotifierProvider(
22 | create: (_) => NoteNotifier(
23 | app: NoteAppService(
24 | factory: const NoteFactory(),
25 | repository:
26 | Provider.of(context, listen: false),
27 | ),
28 | categoryId: category.id,
29 | ),
30 | ),
31 | ChangeNotifierProvider(
32 | create: (_) => TitleEditingController(),
33 | ),
34 | ChangeNotifierProvider(
35 | create: (_) => BodyEditingController(),
36 | ),
37 | ],
38 | child: Scaffold(
39 | appBar: AppBar(title: Text(category.name)),
40 | body: NoteListView(category: category),
41 | floatingActionButton: NoteAddButton(category: category),
42 | ),
43 | );
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/lib/presentation/widget/category/add_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
4 | import 'package:flutter_ddd/presentation/widget/category/edit_dialog.dart';
5 |
6 | class CategoryAddButton extends StatelessWidget {
7 | const CategoryAddButton();
8 |
9 | @override
10 | Widget build(BuildContext context) {
11 | return FloatingActionButton(
12 | child: const Icon(Icons.add),
13 | onPressed: () => CategoryEditDialog(
14 | context: context,
15 | heading: 'New category',
16 | buttonLabel: 'SAVE',
17 | onSave: ({name}) async {
18 | await context.read().saveCategory(name: name);
19 | },
20 | ).show(),
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/presentation/widget/category/category_list_view.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
4 | import 'package:flutter_ddd/presentation/page/note_list.dart';
5 | import 'package:flutter_ddd/presentation/widget/category/edit_button.dart';
6 | import 'package:flutter_ddd/presentation/widget/category/remove_button.dart';
7 |
8 | class CategoryListView extends StatelessWidget {
9 | const CategoryListView();
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | final list = context.select((CategoryNotifier notifier) => notifier.list);
14 |
15 | if (list == null)
16 | return const Center(child: CircularProgressIndicator());
17 | else if (list.isEmpty)
18 | return const Center(
19 | child: Text(
20 | 'No category yet',
21 | style: TextStyle(color: Colors.grey),
22 | ),
23 | );
24 | else
25 | return ListView.builder(
26 | itemCount: list.length,
27 | itemBuilder: (context, index) => _listTile(context, list[index]),
28 | );
29 | }
30 |
31 | Widget _listTile(BuildContext context, CategoryDto category) {
32 | return Card(
33 | child: ListTile(
34 | leading: const IconTheme(
35 | data: IconThemeData(color: Colors.amber),
36 | child: Icon(Icons.folder),
37 | ),
38 | title: Text(category.name),
39 | trailing: Row(
40 | mainAxisSize: MainAxisSize.min,
41 | children: [
42 | CategoryEditButton(category: category),
43 | CategoryRemoveButton(categoryId: category.id),
44 | ],
45 | ),
46 | onTap: () => Navigator.of(context).push(
47 | MaterialPageRoute(
48 | builder: (_) => NoteListPage(category: category),
49 | ),
50 | ),
51 | ),
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/presentation/widget/category/edit_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
4 | import 'package:flutter_ddd/presentation/widget/category/edit_dialog.dart';
5 |
6 | class CategoryEditButton extends StatelessWidget {
7 | final CategoryDto category;
8 |
9 | const CategoryEditButton({@required this.category});
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return IconButton(
14 | icon: const Icon(Icons.edit),
15 | onPressed: () => CategoryEditDialog(
16 | context: context,
17 | heading: 'Edit category',
18 | buttonLabel: 'SAVE',
19 | initialName: category.name,
20 | onSave: ({name}) async {
21 | await context.read().updateCategory(
22 | id: category.id,
23 | name: name,
24 | );
25 | },
26 | ).show(),
27 | );
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/lib/presentation/widget/category/edit_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/common/exception.dart';
4 | import 'package:flutter_ddd/presentation/widget/error_dialog.dart';
5 |
6 | typedef SaveCallback = Future Function({@required String name});
7 |
8 | class CategoryEditDialog extends StatelessWidget {
9 | final BuildContext _context;
10 | final String heading;
11 | final String buttonLabel;
12 | final SaveCallback onSave;
13 | final TextEditingController _nameController;
14 |
15 | CategoryEditDialog({
16 | @required BuildContext context,
17 | @required this.heading,
18 | @required this.buttonLabel,
19 | @required this.onSave,
20 | String initialName,
21 | }) : _context = context,
22 | _nameController = context.read()
23 | ..text = initialName ?? '';
24 |
25 | @override
26 | Widget build(BuildContext context) {
27 | return Center(
28 | child: SingleChildScrollView(
29 | child: AlertDialog(
30 | title: Text(heading),
31 | content: Column(
32 | children: [
33 | TextField(
34 | controller: _nameController,
35 | decoration: const InputDecoration(
36 | labelText: 'Name',
37 | hintText: 'Enter category name',
38 | ),
39 | ),
40 | ],
41 | ),
42 | actions: [
43 | FlatButton(
44 | child: const Text('CANCEL'),
45 | onPressed: () => Navigator.of(context).pop(),
46 | ),
47 | FlatButton(
48 | child: Text(buttonLabel),
49 | onPressed: () async => _onPressed(context),
50 | ),
51 | ],
52 | ),
53 | ),
54 | );
55 | }
56 |
57 | void show() {
58 | showDialog(
59 | context: _context,
60 | builder: build,
61 | );
62 | }
63 |
64 | Future _onPressed(BuildContext context) async {
65 | try {
66 | await onSave(name: _nameController.text);
67 | Navigator.of(context).pop();
68 | } on GenericException catch (e) {
69 | Navigator.of(context).pop();
70 | _showErrorDialog(e.message);
71 | } catch (_) {
72 | Navigator.of(context).pop();
73 | _showErrorDialog('Unknown error occurred.');
74 | }
75 | }
76 |
77 | void _showErrorDialog(String message) {
78 | ErrorDialog(
79 | context: _context,
80 | message: message,
81 | onConfirm: show,
82 | ).show();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/lib/presentation/widget/category/remove_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_ddd/presentation/widget/category/remove_dialog.dart';
3 |
4 | class CategoryRemoveButton extends StatelessWidget {
5 | final String categoryId;
6 |
7 | const CategoryRemoveButton({@required this.categoryId});
8 |
9 | @override
10 | Widget build(BuildContext context) {
11 | return IconButton(
12 | icon: Icon(Icons.delete),
13 | onPressed: () => CategoryRemoveDialog(
14 | context: context,
15 | categoryId: categoryId,
16 | ).show(),
17 | );
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/presentation/widget/category/remove_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/common/exception.dart';
4 | import 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
5 | import 'package:flutter_ddd/presentation/widget/error_dialog.dart';
6 |
7 | class CategoryRemoveDialog extends StatelessWidget {
8 | final BuildContext _context;
9 | final String categoryId;
10 |
11 | const CategoryRemoveDialog({
12 | @required BuildContext context,
13 | @required this.categoryId,
14 | }) : _context = context;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return AlertDialog(
19 | title: const Text('Remove category'),
20 | content: const Text('Are you sure you want to remove this category?'),
21 | actions: [
22 | FlatButton(
23 | child: const Text('CANCEL'),
24 | onPressed: () => Navigator.of(context).pop(),
25 | ),
26 | FlatButton(
27 | child: const Text('REMOVE'),
28 | onPressed: () async {
29 | try {
30 | await _context
31 | .read()
32 | .removeCategory(categoryId);
33 | Navigator.of(context).pop();
34 | } on GenericException catch (e) {
35 | Navigator.of(context).pop();
36 | _showErrorDialog(e.message);
37 | } catch (_) {
38 | Navigator.of(context).pop();
39 | _showErrorDialog('Unknown error occurred.');
40 | }
41 | },
42 | ),
43 | ],
44 | );
45 | }
46 |
47 | void show() {
48 | showDialog(
49 | context: _context,
50 | builder: build,
51 | );
52 | }
53 |
54 | void _showErrorDialog(String message) {
55 | ErrorDialog(
56 | context: _context,
57 | message: message,
58 | ).show();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/presentation/widget/error_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class ErrorDialog extends StatelessWidget {
4 | const ErrorDialog({
5 | @required BuildContext context,
6 | @required this.message,
7 | this.onConfirm,
8 | }) : _context = context;
9 |
10 | final BuildContext _context;
11 | final String message;
12 | final VoidCallback onConfirm;
13 |
14 | @override
15 | Widget build(BuildContext context) {
16 | return AlertDialog(
17 | title: const Text('Error', style: TextStyle(color: Colors.red)),
18 | content: Text(message),
19 | actions: [
20 | RaisedButton(
21 | child: const Text('OK', style: TextStyle(color: Colors.white)),
22 | color: Colors.red,
23 | onPressed: () {
24 | Navigator.of(context).pop();
25 | onConfirm?.call();
26 | },
27 | ),
28 | ],
29 | );
30 | }
31 |
32 | void show() {
33 | showDialog(
34 | context: _context,
35 | builder: build,
36 | );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/add_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/presentation/notifier/note_notifier.dart';
4 | import 'package:flutter_ddd/presentation/widget/note/edit_dialog.dart';
5 |
6 | class NoteAddButton extends StatelessWidget {
7 | final CategoryDto category;
8 |
9 | const NoteAddButton({@required this.category});
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return FloatingActionButton(
14 | child: const Icon(Icons.add),
15 | onPressed: () => NoteEditDialog(
16 | context: context,
17 | heading: 'New note',
18 | buttonLabel: 'SAVE',
19 | category: category,
20 | onSave: ({title, body, categoryId}) async {
21 | await context.read().saveNote(
22 | title: title,
23 | body: body,
24 | categoryId: category.id,
25 | );
26 | },
27 | ).show(),
28 | );
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/dropdown.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_ddd/presentation/widget/note/edit_dialog.dart';
3 |
4 | class CategoryDropdown extends StatefulWidget {
5 | final List list;
6 | final CategoryDto value;
7 | final Function(CategoryDto) onChanged;
8 |
9 | const CategoryDropdown({
10 | @required this.list,
11 | @required this.value,
12 | @required this.onChanged,
13 | });
14 |
15 | @override
16 | _CategoryDropdownState createState() => _CategoryDropdownState();
17 | }
18 |
19 | class _CategoryDropdownState extends State {
20 | CategoryDto _value;
21 |
22 | @override
23 | Widget build(BuildContext context) {
24 | _value ??= widget.value;
25 |
26 | return InputDecorator(
27 | decoration: const InputDecoration(
28 | labelText: 'Category',
29 | ),
30 | child: DropdownButtonHideUnderline(
31 | child: DropdownButton(
32 | isExpanded: true,
33 | isDense: true,
34 | value: _value,
35 | items: widget.list
36 | .map(
37 | (category) => DropdownMenuItem(
38 | value: category,
39 | child: Text(category.name),
40 | ),
41 | )
42 | .toList(),
43 | onChanged: (category) {
44 | setState(() => _value = category);
45 | widget.onChanged(category);
46 | },
47 | ),
48 | ),
49 | );
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/edit_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/presentation/notifier/note_notifier.dart';
4 | import 'package:flutter_ddd/presentation/widget/note/edit_dialog.dart';
5 |
6 | class NoteEditButton extends StatelessWidget {
7 | final CategoryDto category;
8 | final String noteId;
9 |
10 | const NoteEditButton({
11 | @required this.category,
12 | @required this.noteId,
13 | });
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | return IconButton(
18 | icon: const Icon(Icons.edit),
19 | onPressed: () async {
20 | final notifier = context.read();
21 | final note = await notifier.getNote(noteId);
22 |
23 | NoteEditDialog(
24 | context: context,
25 | heading: 'Edit note',
26 | buttonLabel: 'SAVE',
27 | category: category,
28 | onSave: ({title, body, categoryId}) async {
29 | await notifier.updateNote(
30 | id: noteId,
31 | title: title,
32 | body: body,
33 | categoryId: categoryId,
34 | );
35 | },
36 | initialTitle: note.title,
37 | initialBody: note.body,
38 | ).show();
39 | },
40 | );
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/edit_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/common/exception.dart';
4 | import 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
5 | import 'package:flutter_ddd/presentation/widget/error_dialog.dart';
6 | import 'package:flutter_ddd/presentation/widget/note/dropdown.dart';
7 |
8 | export 'package:flutter_ddd/presentation/notifier/category_notifier.dart';
9 |
10 | typedef SaveCallback = Future Function({
11 | @required String title,
12 | @required String body,
13 | @required String categoryId,
14 | });
15 |
16 | class TitleEditingController = TextEditingController with Type;
17 | class BodyEditingController = TextEditingController with Type;
18 |
19 | class NoteEditDialog extends StatelessWidget {
20 | final BuildContext _context;
21 | final String heading;
22 | final String buttonLabel;
23 | final SaveCallback onSave;
24 | final CategoryDto category;
25 | final TitleEditingController _titleController;
26 | final BodyEditingController _bodyController;
27 |
28 | NoteEditDialog({
29 | @required BuildContext context,
30 | @required this.heading,
31 | @required this.buttonLabel,
32 | @required this.onSave,
33 | @required this.category,
34 | String initialTitle,
35 | String initialBody,
36 | }) : _context = context,
37 | _titleController = context.read()
38 | ..text = initialTitle ?? '',
39 | _bodyController = context.read()
40 | ..text = initialBody ?? '';
41 |
42 | @override
43 | Widget build(BuildContext context) {
44 | final categoryNotifier =
45 | Provider.of(_context, listen: false);
46 | CategoryDto selectedCategory = category;
47 |
48 | return Center(
49 | child: SingleChildScrollView(
50 | scrollDirection: Axis.vertical,
51 | child: AlertDialog(
52 | title: Text(heading),
53 | content: Column(
54 | children: [
55 | CategoryDropdown(
56 | list: categoryNotifier.list,
57 | value: selectedCategory,
58 | onChanged: (category) => selectedCategory = category,
59 | ),
60 | TextField(
61 | controller: _titleController,
62 | decoration: const InputDecoration(
63 | labelText: 'Title',
64 | hintText: 'Enter note title',
65 | ),
66 | ),
67 | TextField(
68 | controller: _bodyController,
69 | keyboardType: TextInputType.multiline,
70 | maxLines: null,
71 | minLines: 3,
72 | decoration: const InputDecoration(
73 | labelText: 'Note',
74 | hintText: 'Enter note',
75 | ),
76 | ),
77 | ],
78 | ),
79 | actions: [
80 | FlatButton(
81 | child: const Text('CANCEL'),
82 | onPressed: () => Navigator.of(context).pop(),
83 | ),
84 | FlatButton(
85 | child: Text(buttonLabel),
86 | onPressed: () async => _onPressed(context, selectedCategory),
87 | ),
88 | ],
89 | ),
90 | ),
91 | );
92 | }
93 |
94 | void show() {
95 | showDialog(
96 | context: _context,
97 | builder: build,
98 | );
99 | }
100 |
101 | Future _onPressed(BuildContext context, CategoryDto category) async {
102 | try {
103 | await onSave(
104 | title: _titleController.text,
105 | body: _bodyController.text,
106 | categoryId: category.id,
107 | );
108 | Navigator.of(context).pop();
109 | } on GenericException catch (e) {
110 | Navigator.of(context).pop();
111 | _showErrorDialog(e.message);
112 | } catch (_) {
113 | Navigator.of(context).pop();
114 | _showErrorDialog('Unknown error occurred.');
115 | }
116 | }
117 |
118 | void _showErrorDialog(String message) {
119 | ErrorDialog(
120 | context: _context,
121 | message: message,
122 | onConfirm: show,
123 | ).show();
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/note_list_view.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/application/dto/category_dto.dart';
4 | import 'package:flutter_ddd/presentation/notifier/note_notifier.dart';
5 | import 'package:flutter_ddd/presentation/widget/note/edit_button.dart';
6 | import 'package:flutter_ddd/presentation/widget/note/remove_button.dart';
7 |
8 | class NoteListView extends StatelessWidget {
9 | final CategoryDto category;
10 |
11 | const NoteListView({@required this.category});
12 |
13 | @override
14 | Widget build(BuildContext context) {
15 | final list = context.select((NoteNotifier notifier) => notifier.list);
16 |
17 | if (list == null)
18 | return const Center(child: CircularProgressIndicator());
19 | else if (list.isEmpty)
20 | return const Center(
21 | child: Text(
22 | 'No note yet',
23 | style: TextStyle(color: Colors.grey),
24 | ),
25 | );
26 | else
27 | return ListView.builder(
28 | itemCount: list.length,
29 | itemBuilder: (context, index) => _listTile(context, list[index]),
30 | );
31 | }
32 |
33 | Widget _listTile(BuildContext context, NoteSummaryDto note) {
34 | return Card(
35 | child: ListTile(
36 | leading: const IconTheme(
37 | data: IconThemeData(color: Colors.lime),
38 | child: Icon(Icons.description),
39 | ),
40 | title: Text(note.title),
41 | trailing: Row(
42 | mainAxisSize: MainAxisSize.min,
43 | children: [
44 | NoteEditButton(
45 | noteId: note.id,
46 | category: category,
47 | ),
48 | NoteRemoveButton(noteId: note.id),
49 | ],
50 | ),
51 | ),
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/remove_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_ddd/presentation/widget/note/remove_dialog.dart';
3 |
4 | class NoteRemoveButton extends StatelessWidget {
5 | final String noteId;
6 |
7 | const NoteRemoveButton({@required this.noteId});
8 |
9 | @override
10 | Widget build(BuildContext context) {
11 | return IconButton(
12 | icon: Icon(Icons.delete),
13 | onPressed: () => NoteRemoveDialog(
14 | context: context,
15 | noteId: noteId,
16 | ).show(),
17 | );
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/presentation/widget/note/remove_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:provider/provider.dart';
3 | import 'package:flutter_ddd/common/exception.dart';
4 | import 'package:flutter_ddd/presentation/notifier/note_notifier.dart';
5 | import 'package:flutter_ddd/presentation/widget/error_dialog.dart';
6 |
7 | class NoteRemoveDialog extends StatelessWidget {
8 | final BuildContext _context;
9 | final String noteId;
10 |
11 | const NoteRemoveDialog({
12 | @required BuildContext context,
13 | @required this.noteId,
14 | }) : _context = context;
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return AlertDialog(
19 | title: const Text('Remove note'),
20 | content: const Text('Are you sure you want to remove this note?'),
21 | actions: [
22 | FlatButton(
23 | child: const Text('CANCEL'),
24 | onPressed: () => Navigator.of(context).pop(),
25 | ),
26 | FlatButton(
27 | child: const Text('REMOVE'),
28 | onPressed: () async {
29 | try {
30 | await _context.read().removeNote(noteId);
31 | Navigator.of(context).pop();
32 | } on GenericException catch (e) {
33 | Navigator.of(context).pop();
34 | _showErrorDialog(e.message);
35 | } catch (_) {
36 | Navigator.of(context).pop();
37 | _showErrorDialog('Unknown error occurred.');
38 | }
39 | },
40 | ),
41 | ],
42 | );
43 | }
44 |
45 | void show() {
46 | showDialog(
47 | context: _context,
48 | builder: build,
49 | );
50 | }
51 |
52 | void _showErrorDialog(String message) {
53 | ErrorDialog(
54 | context: _context,
55 | message: message,
56 | ).show();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | archive:
5 | dependency: transitive
6 | description:
7 | name: archive
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "2.0.13"
11 | args:
12 | dependency: transitive
13 | description:
14 | name: args
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "1.6.0"
18 | async:
19 | dependency: transitive
20 | description:
21 | name: async
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "2.4.1"
25 | boolean_selector:
26 | dependency: transitive
27 | description:
28 | name: boolean_selector
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "2.0.0"
32 | charcode:
33 | dependency: transitive
34 | description:
35 | name: charcode
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "1.1.3"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.14.12"
46 | convert:
47 | dependency: transitive
48 | description:
49 | name: convert
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "2.1.1"
53 | crypto:
54 | dependency: transitive
55 | description:
56 | name: crypto
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "2.1.4"
60 | flutter:
61 | dependency: "direct main"
62 | description: flutter
63 | source: sdk
64 | version: "0.0.0"
65 | flutter_test:
66 | dependency: "direct dev"
67 | description: flutter
68 | source: sdk
69 | version: "0.0.0"
70 | image:
71 | dependency: transitive
72 | description:
73 | name: image
74 | url: "https://pub.dartlang.org"
75 | source: hosted
76 | version: "2.1.12"
77 | matcher:
78 | dependency: transitive
79 | description:
80 | name: matcher
81 | url: "https://pub.dartlang.org"
82 | source: hosted
83 | version: "0.12.6"
84 | meta:
85 | dependency: transitive
86 | description:
87 | name: meta
88 | url: "https://pub.dartlang.org"
89 | source: hosted
90 | version: "1.1.8"
91 | nested:
92 | dependency: transitive
93 | description:
94 | name: nested
95 | url: "https://pub.dartlang.org"
96 | source: hosted
97 | version: "0.0.4"
98 | path:
99 | dependency: transitive
100 | description:
101 | name: path
102 | url: "https://pub.dartlang.org"
103 | source: hosted
104 | version: "1.6.4"
105 | petitparser:
106 | dependency: transitive
107 | description:
108 | name: petitparser
109 | url: "https://pub.dartlang.org"
110 | source: hosted
111 | version: "2.4.0"
112 | provider:
113 | dependency: "direct main"
114 | description:
115 | name: provider
116 | url: "https://pub.dartlang.org"
117 | source: hosted
118 | version: "4.3.0"
119 | quiver:
120 | dependency: transitive
121 | description:
122 | name: quiver
123 | url: "https://pub.dartlang.org"
124 | source: hosted
125 | version: "2.1.3"
126 | sky_engine:
127 | dependency: transitive
128 | description: flutter
129 | source: sdk
130 | version: "0.0.99"
131 | source_span:
132 | dependency: transitive
133 | description:
134 | name: source_span
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "1.7.0"
138 | sqflite:
139 | dependency: "direct main"
140 | description:
141 | name: sqflite
142 | url: "https://pub.dartlang.org"
143 | source: hosted
144 | version: "1.3.1"
145 | sqflite_common:
146 | dependency: transitive
147 | description:
148 | name: sqflite_common
149 | url: "https://pub.dartlang.org"
150 | source: hosted
151 | version: "1.0.1"
152 | stack_trace:
153 | dependency: transitive
154 | description:
155 | name: stack_trace
156 | url: "https://pub.dartlang.org"
157 | source: hosted
158 | version: "1.9.3"
159 | stream_channel:
160 | dependency: transitive
161 | description:
162 | name: stream_channel
163 | url: "https://pub.dartlang.org"
164 | source: hosted
165 | version: "2.0.0"
166 | string_scanner:
167 | dependency: transitive
168 | description:
169 | name: string_scanner
170 | url: "https://pub.dartlang.org"
171 | source: hosted
172 | version: "1.0.5"
173 | synchronized:
174 | dependency: transitive
175 | description:
176 | name: synchronized
177 | url: "https://pub.dartlang.org"
178 | source: hosted
179 | version: "2.1.1"
180 | term_glyph:
181 | dependency: transitive
182 | description:
183 | name: term_glyph
184 | url: "https://pub.dartlang.org"
185 | source: hosted
186 | version: "1.1.0"
187 | test_api:
188 | dependency: transitive
189 | description:
190 | name: test_api
191 | url: "https://pub.dartlang.org"
192 | source: hosted
193 | version: "0.2.15"
194 | typed_data:
195 | dependency: transitive
196 | description:
197 | name: typed_data
198 | url: "https://pub.dartlang.org"
199 | source: hosted
200 | version: "1.1.6"
201 | uuid:
202 | dependency: "direct main"
203 | description:
204 | name: uuid
205 | url: "https://pub.dartlang.org"
206 | source: hosted
207 | version: "2.2.0"
208 | vector_math:
209 | dependency: transitive
210 | description:
211 | name: vector_math
212 | url: "https://pub.dartlang.org"
213 | source: hosted
214 | version: "2.0.8"
215 | xml:
216 | dependency: transitive
217 | description:
218 | name: xml
219 | url: "https://pub.dartlang.org"
220 | source: hosted
221 | version: "3.6.1"
222 | sdks:
223 | dart: ">=2.7.0 <3.0.0"
224 | flutter: ">=1.16.0 <2.0.0"
225 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_ddd
2 | description: A new Flutter project.
3 |
4 | version: 1.0.0+1
5 |
6 | environment:
7 | sdk: ">=2.7.0 <3.0.0"
8 |
9 | dependencies:
10 | flutter:
11 | sdk: flutter
12 |
13 | provider: ^4.3.0
14 | sqflite: ^1.3.1
15 | uuid: ^2.2.0
16 |
17 | dev_dependencies:
18 | flutter_test:
19 | sdk: flutter
20 |
21 | flutter:
22 | uses-material-design: true
23 |
--------------------------------------------------------------------------------
/test/category_app_service_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_test/flutter_test.dart';
2 |
3 | import 'package:flutter_ddd/common/exception.dart';
4 | import 'package:flutter_ddd/application/category_app_service.dart';
5 | import 'package:flutter_ddd/infrastructure/category/category_factory.dart';
6 |
7 | import 'infrastructure/category_repository.dart';
8 | import 'infrastructure/note_repository.dart';
9 |
10 | void main() {
11 | final repository = CategoryRepository();
12 | final noteRepository = NoteRepository();
13 |
14 | final app = CategoryAppService(
15 | factory: const CategoryFactory(),
16 | repository: repository,
17 | noteRepository: noteRepository,
18 | );
19 |
20 | group('Category', () {
21 | test('registering existing name should fail', () async {
22 | noteRepository.clear();
23 | repository.clear();
24 |
25 | await app.saveCategory(name: 'category name');
26 |
27 | bool isSuccessful = true;
28 | try {
29 | await app.saveCategory(name: 'category name');
30 | } catch (e) {
31 | if (e.runtimeType == NotUniqueException) {
32 | isSuccessful = false;
33 | }
34 | }
35 |
36 | expect(isSuccessful, false);
37 | });
38 |
39 | test('new category should be registered', () async {
40 | repository.clear();
41 | noteRepository.clear();
42 |
43 | await app.saveCategory(name: 'category name');
44 |
45 | final categories = await app.getCategoryList();
46 | expect(categories.length, 1);
47 | });
48 |
49 | test('update without change should be successful', () async {
50 | repository.clear();
51 | noteRepository.clear();
52 |
53 | await app.saveCategory(name: 'category name');
54 |
55 | final categories = await app.getCategoryList();
56 |
57 | bool isSuccessful = true;
58 | try {
59 | await app.updateCategory(
60 | id: categories[0].id,
61 | name: 'category name',
62 | );
63 | } catch (_) {
64 | isSuccessful = false;
65 | }
66 |
67 | expect(isSuccessful, true);
68 | });
69 |
70 | test('category should be removed', () async {
71 | repository.clear();
72 | noteRepository.clear();
73 |
74 | await app.saveCategory(name: 'category name');
75 |
76 | final categories = await app.getCategoryList();
77 | await app.removeCategory(categories[0].id);
78 |
79 | expect(await app.getCategoryList(), isEmpty);
80 | });
81 | });
82 | }
83 |
--------------------------------------------------------------------------------
/test/infrastructure/category_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_ddd/domain/category/category.dart';
2 | import 'package:flutter_ddd/domain/category/category_repository_base.dart';
3 |
4 | export 'package:flutter_ddd/domain/category/category_repository_base.dart';
5 |
6 | class CategoryRepository implements CategoryRepositoryBase {
7 | final _data = {};
8 |
9 | @override
10 | Future transaction(Future Function() f) async {
11 | return await f();
12 | }
13 |
14 | @override
15 | Future find(CategoryId id) {
16 | final category = _data[id];
17 |
18 | if (category == null) {
19 | return null;
20 | }
21 |
22 | final clonedNote = Category(
23 | id: category.id,
24 | name: category.name,
25 | );
26 |
27 | return Future.value(clonedNote);
28 | }
29 |
30 | @override
31 | Future findByName(CategoryName name) {
32 | final category = _data.values.firstWhere(
33 | (category) => category.name == name,
34 | orElse: () => null,
35 | );
36 |
37 | if (category == null) {
38 | return null;
39 | }
40 |
41 | final clonedNote = Category(
42 | id: category.id,
43 | name: category.name,
44 | );
45 |
46 | return Future.value(clonedNote);
47 | }
48 |
49 | @override
50 | Future> findAll() {
51 | final clonedNotes = List.unmodifiable(_data.values);
52 | return Future.value(clonedNotes);
53 | }
54 |
55 | @override
56 | Future save(Category category) {
57 | _data[category.id] = category;
58 | return null;
59 | }
60 |
61 | @override
62 | Future remove(Category category) {
63 | _data.remove(category.id);
64 | return null;
65 | }
66 |
67 | void clear() {
68 | _data.clear();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/test/infrastructure/note_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_ddd/domain/note/note.dart';
2 | import 'package:flutter_ddd/domain/note/note_repository_base.dart';
3 |
4 | export 'package:flutter_ddd/domain/note/note_repository_base.dart';
5 |
6 | class NoteRepository implements NoteRepositoryBase {
7 | final _data = {};
8 |
9 | @override
10 | Future transaction(Future Function() f) async {
11 | return await f();
12 | }
13 |
14 | @override
15 | Future find(NoteId id) {
16 | final note = _data[id];
17 |
18 | if (note == null) {
19 | return null;
20 | }
21 |
22 | final clonedNote = Note(
23 | id: note.id,
24 | title: note.title,
25 | body: note.body,
26 | categoryId: note.categoryId,
27 | );
28 |
29 | return Future.value(clonedNote);
30 | }
31 |
32 | @override
33 | Future findByTitle(NoteTitle title) {
34 | final note = _data.values.firstWhere(
35 | (note) => note.title == title,
36 | orElse: () => null,
37 | );
38 |
39 | if (note == null) {
40 | return null;
41 | }
42 |
43 | final clonedNote = Note(
44 | id: note.id,
45 | title: note.title,
46 | body: note.body,
47 | categoryId: note.categoryId,
48 | );
49 |
50 | return Future.value(clonedNote);
51 | }
52 |
53 | @override
54 | Future> findByCategory(CategoryId categoryId) {
55 | final clonedNotes = _data.values
56 | .where((note) => note.categoryId == categoryId)
57 | .map((note) => Note(
58 | id: note.id,
59 | title: note.title,
60 | body: note.body,
61 | categoryId: categoryId,
62 | ))
63 | .toList();
64 |
65 | return Future.value(clonedNotes);
66 | }
67 |
68 | @override
69 | Future countByCategory(CategoryId categoryId) {
70 | final count =
71 | _data.values.where((note) => note.categoryId == categoryId).length;
72 |
73 | return Future.value(count);
74 | }
75 |
76 | @override
77 | Future save(Note note) {
78 | _data[note.id] = note;
79 | return null;
80 | }
81 |
82 | @override
83 | Future remove(Note note) {
84 | _data.remove(note.id);
85 | return null;
86 | }
87 |
88 | void clear() {
89 | _data.clear();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/test/note_app_service_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_test/flutter_test.dart';
2 |
3 | import 'package:flutter_ddd/application/note_app_service.dart';
4 | import 'package:flutter_ddd/common/exception.dart';
5 | import 'package:flutter_ddd/infrastructure/note/note_factory.dart';
6 |
7 | import 'infrastructure/note_repository.dart';
8 |
9 | void main() {
10 | final repository = NoteRepository();
11 |
12 | final app = NoteAppService(
13 | factory: const NoteFactory(),
14 | repository: repository,
15 | );
16 |
17 | group('Note', () {
18 | test('registering existing title should fail', () async {
19 | repository.clear();
20 |
21 | await app.saveNote(
22 | title: 'note title',
23 | body: 'note body',
24 | categoryId: 'category id',
25 | );
26 |
27 | bool isSuccessful = true;
28 | try {
29 | await app.saveNote(
30 | title: 'note title',
31 | body: 'note body 2',
32 | categoryId: 'category id 2',
33 | );
34 | } catch (e) {
35 | if (e.runtimeType == NotUniqueException) {
36 | isSuccessful = false;
37 | }
38 | }
39 |
40 | expect(isSuccessful, false);
41 | });
42 |
43 | test('new note should be registered', () async {
44 | repository.clear();
45 |
46 | await app.saveNote(
47 | title: 'note title',
48 | body: 'note body',
49 | categoryId: 'category id',
50 | );
51 |
52 | final notes = await app.getNoteList('category id');
53 | expect(notes.length, 1);
54 | });
55 |
56 | test('update without change in title should be successful', () async {
57 | repository.clear();
58 |
59 | await app.saveNote(
60 | title: 'note title',
61 | body: 'note body',
62 | categoryId: 'category id',
63 | );
64 |
65 | final notes = await app.getNoteList('category id');
66 |
67 | bool isSuccessful = true;
68 | try {
69 | await app.updateNote(
70 | id: notes[0].id,
71 | title: 'note title',
72 | body: 'note body 2',
73 | categoryId: 'category id',
74 | );
75 | } catch (_) {
76 | isSuccessful = false;
77 | }
78 |
79 | expect(isSuccessful, true);
80 | });
81 |
82 | test('note should be moved to another category', () async {
83 | repository.clear();
84 |
85 | await app.saveNote(
86 | title: 'note title',
87 | body: 'note body',
88 | categoryId: 'category id 1',
89 | );
90 |
91 | List notes = await app.getNoteList('category id 1');
92 | expect(notes.length, 1);
93 |
94 | await app.updateNote(
95 | id: notes[0].id,
96 | title: 'note title',
97 | body: 'note body',
98 | categoryId: 'category id 2',
99 | );
100 |
101 | notes = await app.getNoteList('category id 1');
102 | expect(notes.length, 0);
103 |
104 | notes = await app.getNoteList('category id 2');
105 | expect(notes.length, 1);
106 | });
107 |
108 | test('note should be removed', () async {
109 | repository.clear();
110 |
111 | await app.saveNote(
112 | title: 'note title',
113 | body: 'note body',
114 | categoryId: 'category id',
115 | );
116 |
117 | final notes = await app.getNoteList('category id');
118 | await app.removeNote(notes[0].id);
119 |
120 | final note = await app.getNote(notes[0].id);
121 | expect(note, isNull);
122 | });
123 | });
124 | }
125 |
--------------------------------------------------------------------------------