├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── todo │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── constants.dart ├── features │ └── todo │ │ ├── domain │ │ ├── todo_domain_importer.dart │ │ ├── todo_item │ │ │ ├── todo_item.dart │ │ │ └── todo_item.freezed.dart │ │ └── todo_list │ │ │ ├── todo_list.dart │ │ │ └── todo_list.freezed.dart │ │ ├── infrastructure │ │ ├── dto │ │ │ ├── todo_dto.dart │ │ │ └── todo_dto.g.dart │ │ ├── todo_infrastructure_importer.dart │ │ └── todo_repository.dart │ │ ├── presentation │ │ ├── create_or_edit_todo │ │ │ └── create_or_edit_todo_page.dart │ │ ├── garbage_todo_list │ │ │ ├── garbage_todo_list_notifier.dart │ │ │ └── garbage_todo_list_page.dart │ │ ├── todo_list │ │ │ ├── todo_list_page.dart │ │ │ └── widgets │ │ │ │ └── todo_drawer.dart │ │ ├── todo_list_notifier.dart │ │ ├── todo_presentation_importer.dart │ │ └── widgets │ │ │ ├── snack_bar.dart │ │ │ └── todo_card.dart │ │ └── usecase │ │ ├── add_todo_usecase.dart │ │ ├── change_to_garbage_status_usecase.dart │ │ ├── custom_exception.dart │ │ ├── delete_todos_usecase.dart │ │ ├── edit_todo_usecase.dart │ │ ├── fetch_garbage_todos_usecase.dart │ │ ├── fetch_todos_usecase.dart │ │ └── todo_usecase_importer.dart ├── main.dart ├── router.dart └── theme.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── test └── widget_test.dart ├── todo_demo.gif ├── todo_demo.mov ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /.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. 5 | 6 | version: 7 | revision: 135454af32477f815a7525073027a3ff9eff1bfd 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 17 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 18 | - platform: android 19 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 20 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 21 | - platform: ios 22 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 23 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 24 | - platform: linux 25 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 26 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 27 | - platform: macos 28 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 29 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 30 | - platform: web 31 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 32 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 33 | - platform: windows 34 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 35 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TODO アプリ 2 | 3 | このアプリは Flutter を使用した TODO アプリです。 4 | Flutter の開発で必要な基本知識の習得に役立てそうなリポジトリです。 5 | 6 | ## このアプリの特徴 7 | 8 | 本アプリでは以下の特徴を持っています。 9 | 10 | - メモの追加、編集、削除、取得 11 | - アーカイブ機能(ゴミ箱) 12 | - メモのページング機能 13 | - ゴミ箱に存在しているメモの自動削除機能 14 | - SnackBar の表示、取消機能 15 | 16 | ![todo_demo](https://user-images.githubusercontent.com/62784463/213902973-4a278e61-57e1-416b-a333-bc62ff51ba8b.gif) 17 | 18 | ## アプリで使用したパッケージ 19 | 20 | ### 1. Riverpod 21 | 22 | このアプリでは [Riverpod](https://pub.dev/packages/flutter_riverpod)を使用した状態管理をしています。Riverpod の基本的な使い方を取り入れているつもりです。Reverpod 2.0 系に対応しています。 23 | 24 | ### 2. GoRouter 25 | 26 | 画面遷移には[GoRouter](https://pub.dev/packages/go_router)を使用しています。宣言的な遷移を実現でき、Flutter の公式パッケージとなっています。応用的な取り扱いはしていないため、基礎を習得するレベルとなります。 27 | 28 | ### 3. Isar 29 | 30 | ローカルのデータベースには[Isar Database](https://pub.dev/packages/isar)を使用しています。ドキュメントも充実しており、使い方もシンプルでおすすめです。作成、更新、読取、削除の基本的な扱い方はこのアプリ内で使用されています。残念なところは Freezed と併用することができず、実装には少し工夫が必要です。 31 | 32 | ### 4. logger 33 | 34 | ログの取得には[logger](https://pub.dev/packages/logger)を使用しています。print 関数は基本的に使用することを避けています。ログ出力関連のパッケージは他にも存在していますが、オーソドックスのものを使用しています。 35 | 36 | ### 5. Freezed 37 | 38 | immutable なプログラミングを実施する上で、必要な[Freezed](https://pub.dev/packages/freezed)を使用しています。本アプリではデータモデルの作成に利用していますが、ドメイン知識のロジックについては method にも定義するようにしています(DDD 的な考え方を利用)。 39 | 40 | ### 6. Dart Code Metrics 41 | 42 | lint のルールを増やしたり、不要なファイルなどを教えてくれる[Dart Code Metrics](https://pub.dev/packages/dart_code_metrics)を使用しています。[flutter_lints](https://pub.dev/packages/flutter_lints)と併用させており、コードの書き方を統一させることができるため、推奨したいパッケージです。 43 | 44 | ## ドメイン駆動開発の手法を取り入れた実装 45 | 46 | このアプリではドメイン駆動開発(DDD)の思想を取り入れています。ただ、全ての要素を取り入れているわけではなく、重要だと思われるところを取り入れています。**Flutter の設計において「これだ!」という設計手法は存在しない**ため、参考程度に見ていただくのが良いと思います。 47 | 48 | ### ・ドメイン知識はドメインのクラスに記述する 49 | 50 | 個人的にドメイン駆動開発において最も重要な点と考えています。ViewModel に相当する部分(Notifier や AsyncNotifier を使用している箇所)のコードが肥大化することがしばしば見られます。これはアプリケーションロジック(状態変化をさせるコードなど)とドメイン由来のロジック(ドメインモデルを使った計算、ドメインモデルを使った判断)が混在するためです。 51 | 52 | 例えば、以下のようなコードがあるとします。 53 | 54 | ```dart 55 | @freezed 56 | class TodoList with _$TodoList { 57 | const factory TodoList({ 58 | required List items, 59 | @Default(false) bool hasReachedMax, 60 | }) = _TodoList; 61 | } 62 | ``` 63 | 64 | これはメモのリストを保持するクラスです。プロパティを定義しているものの、ドメイン由来のロジックは記述されていません。このようなコードはドメインに関するロジックは ViewModel 側で記述されることになります。一方、次のコードだとドメインに関するロジックが含まれています。 65 | 66 | ```dart 67 | @freezed 68 | class TodoList with _$TodoList { 69 | const TodoList._(); 70 | 71 | const factory TodoList({ 72 | required List items, 73 | @Default(false) bool hasReachedMax, 74 | }) = _TodoList; 75 | 76 | TodoList fetch(List todoItemList) { 77 | final hasReachedMax = todoItemList.length < page; 78 | 79 | return copyWith( 80 | items: [...items, ...todoItemList], 81 | hasReachedMax: hasReachedMax, 82 | ); 83 | } 84 | 85 | int get length => items.length; 86 | 87 | TodoList add(TodoItem item) => copyWith(items: [item, ...items]); 88 | 89 | TodoList edit(TodoItem todoItem) { 90 | final index = items.map((item) => item.id).toList().indexOf(todoItem.id); 91 | 92 | final editedItem = List.of(items) 93 | ..removeAt(index) 94 | ..insert(0, todoItem); 95 | 96 | return copyWith(items: editedItem); 97 | } 98 | 99 | TodoList remove(TodoItem todoItem) { 100 | final index = items.map((item) => item.id).toList().indexOf(todoItem.id); 101 | final removedItem = List.of(items)..removeAt(index); 102 | 103 | return copyWith(items: removedItem); 104 | } 105 | 106 | TodoList insert(TodoItem todoItem, int index) { 107 | final insertedItem = List.of(items)..insert(index, todoItem); 108 | 109 | return copyWith(items: insertedItem); 110 | } 111 | } 112 | ``` 113 | 114 | このように記述することで、ViewModel 側のコード肥大を防ぐことができるだけでなく、あちこちにドメインに由来するロジックが散らばることも防ぐことができます。 115 | 116 | ### ・適切にディレクトリ構成を分ける 117 | 118 | 今回は基本的な4つの層にディレクトリを分けています。**必ず全ての層を利用しなければならないこともなく**、この辺りは層を分ける理由を明確にしておくことが重要です。本アプリでは、以下のような構成にしています。 119 | 120 |
121 |
Presentation層
122 |
画面表示部分を表します。ViewModelもこちらに記載します。
123 |
124 |
ドメイン層
125 |
アプリで必要なモデル情報を記述しています。ドメインに関するロジックもこちらに含めています。
126 |
127 |
Usecase層
128 |
エラー処理とアプリケーションロジックを記載しています。アプリケーションロジックがなく、エラー処理だけの場合もあります。
129 |
130 |
Infrastructure層
131 |
データの永続化などを行います。Isarパッケージの影響によりDTO(データ転送用のオブジェクト)もこちらに含めています。 132 |
133 |
134 |
135 | 136 | ### ・他の DDD 的手法 137 | 138 | 他にはファーストクラスオブジェクト、前項で記述した DTO(Data Transfer Object)なども取り入れています。他にも DDD の要素はあると思いますが、アプリの規模・フレームワーク上の都合に合わせて適切に使用すれば良いと個人的には思います。 139 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | analyzer: 13 | plugins: 14 | - dart_code_metrics 15 | errors: 16 | invalid_annotation_target: ignore 17 | use_build_context_synchronously: ignore 18 | exclude: 19 | - /**.freezed.dart 20 | - /**.g.dart 21 | 22 | dart_code_metrics: 23 | metrics: 24 | cyclomatic-complexity: 20 25 | number-of-parameters: 4 26 | maximum-nesting-level: 5 27 | metrics-exclude: 28 | - test/** 29 | rules: 30 | - newline-before-return 31 | - no-boolean-literal-compare 32 | - no-empty-block 33 | - prefer-trailing-comma 34 | - prefer-conditional-expressions 35 | - no-equal-then-else 36 | anti-patterns: 37 | - long-method 38 | - long-parameter-list 39 | 40 | linter: 41 | # The lint rules applied to this project can be customized in the 42 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 43 | # included above or to enable additional rules. A list of all available lints 44 | # and their documentation is published at 45 | # https://dart-lang.github.io/linter/lints/index.html. 46 | # 47 | # Instead of disabling a lint rule for the entire project in the 48 | # section below, it can also be suppressed for a single line of code 49 | # or a specific dart file by using the `// ignore: name_of_lint` and 50 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 51 | # producing the lint. 52 | rules: 53 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 54 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 55 | depend_on_referenced_packages: false 56 | # Additional information about this file can be found at 57 | # https://dart.dev/guides/language/analysis-options 58 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.example.todo" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/todo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.todo 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.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, '11.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 flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - isar_flutter_libs (1.0.0): 4 | - Flutter 5 | 6 | DEPENDENCIES: 7 | - Flutter (from `Flutter`) 8 | - isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`) 9 | 10 | EXTERNAL SOURCES: 11 | Flutter: 12 | :path: Flutter 13 | isar_flutter_libs: 14 | :path: ".symlinks/plugins/isar_flutter_libs/ios" 15 | 16 | SPEC CHECKSUMS: 17 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 18 | isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073 19 | 20 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 21 | 22 | COCOAPODS: 1.11.3 23 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Todo 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | todo 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/constants.dart: -------------------------------------------------------------------------------- 1 | /// メモを取得する個数(ページング取得数) 2 | const int page = 10; 3 | 4 | /// ゴミ箱に存在しているメモがローカルから削除されるタイミング 5 | const int deletedDurationDays = 90; 6 | -------------------------------------------------------------------------------- /lib/features/todo/domain/todo_domain_importer.dart: -------------------------------------------------------------------------------- 1 | export 'package:todo/features/todo/domain/todo_item/todo_item.dart'; 2 | export 'package:todo/features/todo/domain/todo_list/todo_list.dart'; 3 | -------------------------------------------------------------------------------- /lib/features/todo/domain/todo_item/todo_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:freezed_annotation/freezed_annotation.dart'; 3 | import 'package:intl/intl.dart'; 4 | 5 | part 'todo_item.freezed.dart'; 6 | 7 | /// メモのドメイン 8 | /// 9 | /// ドメインに関するロジックはできる限り、ドメインクラスに記載すること。 10 | @freezed 11 | class TodoItem with _$TodoItem { 12 | // メソッドを追加する場合はプライベートコンストラクターを定義します。 13 | const TodoItem._(); 14 | 15 | const factory TodoItem({ 16 | /// メモを識別するユニークなid 17 | /// 18 | /// isarのidの型がintのため、ドメインのidもintとしています。 19 | required int id, 20 | 21 | /// メモのタイトル 22 | required String title, 23 | 24 | /// メモの内容 25 | required String discription, 26 | 27 | /// メモの作成日 28 | /// 29 | /// 現状、使用している箇所は特にありません。 30 | required DateTime createAt, 31 | 32 | /// ゴミ箱に入っているか否か 33 | /// 34 | /// このアプリではメモを一旦ゴミ箱に格納し、 35 | /// 90日経過するとゴミ箱からメモが完全に削除される設定としています。 36 | required bool isGarbage, 37 | 38 | /// メモの更新日 39 | /// 40 | /// メモの更新日はisarデータベースにてソート対象となります。 41 | /// 日付が近い日から順番にメモを表示させます。 42 | required DateTime updatedAt, 43 | }) = _TodoItem; 44 | 45 | TodoItem toGarbage({required bool toGabage}) => copyWith(isGarbage: toGabage); 46 | 47 | TodoItem updateDateTime() => copyWith(updatedAt: DateTime.now()); 48 | 49 | TodoItem update({required String title, required String discription}) => 50 | copyWith( 51 | title: title, 52 | discription: discription, 53 | updatedAt: DateTime.now(), 54 | ); 55 | 56 | String get updatedAtText { 57 | final formatter = DateFormat('yyyy年MM月dd日(E)HH:mm', 'ja'); 58 | 59 | return formatter.format(updatedAt); 60 | } 61 | 62 | bool get isEmptyTitle => title.isEmpty; 63 | 64 | bool get isEmptyDiscription => discription.isEmpty; 65 | } 66 | -------------------------------------------------------------------------------- /lib/features/todo/domain/todo_item/todo_item.freezed.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | // GENERATED CODE - DO NOT MODIFY BY HAND 3 | // ignore_for_file: type=lint 4 | // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark 5 | 6 | part of 'todo_item.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | T _$identity(T value) => value; 13 | 14 | final _privateConstructorUsedError = UnsupportedError( 15 | 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 16 | 17 | /// @nodoc 18 | mixin _$TodoItem { 19 | /// メモを識別するユニークなid 20 | /// 21 | /// isarのidの型がintのため、ドメインのidもintとしています。 22 | int get id => throw _privateConstructorUsedError; 23 | 24 | /// メモのタイトル 25 | String get title => throw _privateConstructorUsedError; 26 | 27 | /// メモの内容 28 | String get discription => throw _privateConstructorUsedError; 29 | 30 | /// メモの作成日 31 | /// 32 | /// 現状、使用している箇所は特にありません。 33 | DateTime get createAt => throw _privateConstructorUsedError; 34 | 35 | /// ゴミ箱に入っているか否か 36 | /// 37 | /// このアプリではメモを一旦ゴミ箱に格納し、 38 | /// 90日経過するとゴミ箱からメモが完全に削除される設定としています。 39 | bool get isGarbage => throw _privateConstructorUsedError; 40 | 41 | /// メモの更新日 42 | /// 43 | /// メモの更新日はisarデータベースにてソート対象となります。 44 | /// 日付が近い日から順番にメモを表示させます。 45 | DateTime get updatedAt => throw _privateConstructorUsedError; 46 | 47 | @JsonKey(ignore: true) 48 | $TodoItemCopyWith get copyWith => 49 | throw _privateConstructorUsedError; 50 | } 51 | 52 | /// @nodoc 53 | abstract class $TodoItemCopyWith<$Res> { 54 | factory $TodoItemCopyWith(TodoItem value, $Res Function(TodoItem) then) = 55 | _$TodoItemCopyWithImpl<$Res, TodoItem>; 56 | @useResult 57 | $Res call( 58 | {int id, 59 | String title, 60 | String discription, 61 | DateTime createAt, 62 | bool isGarbage, 63 | DateTime updatedAt}); 64 | } 65 | 66 | /// @nodoc 67 | class _$TodoItemCopyWithImpl<$Res, $Val extends TodoItem> 68 | implements $TodoItemCopyWith<$Res> { 69 | _$TodoItemCopyWithImpl(this._value, this._then); 70 | 71 | // ignore: unused_field 72 | final $Val _value; 73 | // ignore: unused_field 74 | final $Res Function($Val) _then; 75 | 76 | @pragma('vm:prefer-inline') 77 | @override 78 | $Res call({ 79 | Object? id = null, 80 | Object? title = null, 81 | Object? discription = null, 82 | Object? createAt = null, 83 | Object? isGarbage = null, 84 | Object? updatedAt = null, 85 | }) { 86 | return _then(_value.copyWith( 87 | id: null == id 88 | ? _value.id 89 | : id // ignore: cast_nullable_to_non_nullable 90 | as int, 91 | title: null == title 92 | ? _value.title 93 | : title // ignore: cast_nullable_to_non_nullable 94 | as String, 95 | discription: null == discription 96 | ? _value.discription 97 | : discription // ignore: cast_nullable_to_non_nullable 98 | as String, 99 | createAt: null == createAt 100 | ? _value.createAt 101 | : createAt // ignore: cast_nullable_to_non_nullable 102 | as DateTime, 103 | isGarbage: null == isGarbage 104 | ? _value.isGarbage 105 | : isGarbage // ignore: cast_nullable_to_non_nullable 106 | as bool, 107 | updatedAt: null == updatedAt 108 | ? _value.updatedAt 109 | : updatedAt // ignore: cast_nullable_to_non_nullable 110 | as DateTime, 111 | ) as $Val); 112 | } 113 | } 114 | 115 | /// @nodoc 116 | abstract class _$$_TodoItemCopyWith<$Res> implements $TodoItemCopyWith<$Res> { 117 | factory _$$_TodoItemCopyWith( 118 | _$_TodoItem value, $Res Function(_$_TodoItem) then) = 119 | __$$_TodoItemCopyWithImpl<$Res>; 120 | @override 121 | @useResult 122 | $Res call( 123 | {int id, 124 | String title, 125 | String discription, 126 | DateTime createAt, 127 | bool isGarbage, 128 | DateTime updatedAt}); 129 | } 130 | 131 | /// @nodoc 132 | class __$$_TodoItemCopyWithImpl<$Res> 133 | extends _$TodoItemCopyWithImpl<$Res, _$_TodoItem> 134 | implements _$$_TodoItemCopyWith<$Res> { 135 | __$$_TodoItemCopyWithImpl( 136 | _$_TodoItem _value, $Res Function(_$_TodoItem) _then) 137 | : super(_value, _then); 138 | 139 | @pragma('vm:prefer-inline') 140 | @override 141 | $Res call({ 142 | Object? id = null, 143 | Object? title = null, 144 | Object? discription = null, 145 | Object? createAt = null, 146 | Object? isGarbage = null, 147 | Object? updatedAt = null, 148 | }) { 149 | return _then(_$_TodoItem( 150 | id: null == id 151 | ? _value.id 152 | : id // ignore: cast_nullable_to_non_nullable 153 | as int, 154 | title: null == title 155 | ? _value.title 156 | : title // ignore: cast_nullable_to_non_nullable 157 | as String, 158 | discription: null == discription 159 | ? _value.discription 160 | : discription // ignore: cast_nullable_to_non_nullable 161 | as String, 162 | createAt: null == createAt 163 | ? _value.createAt 164 | : createAt // ignore: cast_nullable_to_non_nullable 165 | as DateTime, 166 | isGarbage: null == isGarbage 167 | ? _value.isGarbage 168 | : isGarbage // ignore: cast_nullable_to_non_nullable 169 | as bool, 170 | updatedAt: null == updatedAt 171 | ? _value.updatedAt 172 | : updatedAt // ignore: cast_nullable_to_non_nullable 173 | as DateTime, 174 | )); 175 | } 176 | } 177 | 178 | /// @nodoc 179 | 180 | class _$_TodoItem extends _TodoItem with DiagnosticableTreeMixin { 181 | const _$_TodoItem( 182 | {required this.id, 183 | required this.title, 184 | required this.discription, 185 | required this.createAt, 186 | required this.isGarbage, 187 | required this.updatedAt}) 188 | : super._(); 189 | 190 | /// メモを識別するユニークなid 191 | /// 192 | /// isarのidの型がintのため、ドメインのidもintとしています。 193 | @override 194 | final int id; 195 | 196 | /// メモのタイトル 197 | @override 198 | final String title; 199 | 200 | /// メモの内容 201 | @override 202 | final String discription; 203 | 204 | /// メモの作成日 205 | /// 206 | /// 現状、使用している箇所は特にありません。 207 | @override 208 | final DateTime createAt; 209 | 210 | /// ゴミ箱に入っているか否か 211 | /// 212 | /// このアプリではメモを一旦ゴミ箱に格納し、 213 | /// 90日経過するとゴミ箱からメモが完全に削除される設定としています。 214 | @override 215 | final bool isGarbage; 216 | 217 | /// メモの更新日 218 | /// 219 | /// メモの更新日はisarデータベースにてソート対象となります。 220 | /// 日付が近い日から順番にメモを表示させます。 221 | @override 222 | final DateTime updatedAt; 223 | 224 | @override 225 | String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { 226 | return 'TodoItem(id: $id, title: $title, discription: $discription, createAt: $createAt, isGarbage: $isGarbage, updatedAt: $updatedAt)'; 227 | } 228 | 229 | @override 230 | void debugFillProperties(DiagnosticPropertiesBuilder properties) { 231 | super.debugFillProperties(properties); 232 | properties 233 | ..add(DiagnosticsProperty('type', 'TodoItem')) 234 | ..add(DiagnosticsProperty('id', id)) 235 | ..add(DiagnosticsProperty('title', title)) 236 | ..add(DiagnosticsProperty('discription', discription)) 237 | ..add(DiagnosticsProperty('createAt', createAt)) 238 | ..add(DiagnosticsProperty('isGarbage', isGarbage)) 239 | ..add(DiagnosticsProperty('updatedAt', updatedAt)); 240 | } 241 | 242 | @override 243 | bool operator ==(dynamic other) { 244 | return identical(this, other) || 245 | (other.runtimeType == runtimeType && 246 | other is _$_TodoItem && 247 | (identical(other.id, id) || other.id == id) && 248 | (identical(other.title, title) || other.title == title) && 249 | (identical(other.discription, discription) || 250 | other.discription == discription) && 251 | (identical(other.createAt, createAt) || 252 | other.createAt == createAt) && 253 | (identical(other.isGarbage, isGarbage) || 254 | other.isGarbage == isGarbage) && 255 | (identical(other.updatedAt, updatedAt) || 256 | other.updatedAt == updatedAt)); 257 | } 258 | 259 | @override 260 | int get hashCode => Object.hash( 261 | runtimeType, id, title, discription, createAt, isGarbage, updatedAt); 262 | 263 | @JsonKey(ignore: true) 264 | @override 265 | @pragma('vm:prefer-inline') 266 | _$$_TodoItemCopyWith<_$_TodoItem> get copyWith => 267 | __$$_TodoItemCopyWithImpl<_$_TodoItem>(this, _$identity); 268 | } 269 | 270 | abstract class _TodoItem extends TodoItem { 271 | const factory _TodoItem( 272 | {required final int id, 273 | required final String title, 274 | required final String discription, 275 | required final DateTime createAt, 276 | required final bool isGarbage, 277 | required final DateTime updatedAt}) = _$_TodoItem; 278 | const _TodoItem._() : super._(); 279 | 280 | @override 281 | 282 | /// メモを識別するユニークなid 283 | /// 284 | /// isarのidの型がintのため、ドメインのidもintとしています。 285 | int get id; 286 | @override 287 | 288 | /// メモのタイトル 289 | String get title; 290 | @override 291 | 292 | /// メモの内容 293 | String get discription; 294 | @override 295 | 296 | /// メモの作成日 297 | /// 298 | /// 現状、使用している箇所は特にありません。 299 | DateTime get createAt; 300 | @override 301 | 302 | /// ゴミ箱に入っているか否か 303 | /// 304 | /// このアプリではメモを一旦ゴミ箱に格納し、 305 | /// 90日経過するとゴミ箱からメモが完全に削除される設定としています。 306 | bool get isGarbage; 307 | @override 308 | 309 | /// メモの更新日 310 | /// 311 | /// メモの更新日はisarデータベースにてソート対象となります。 312 | /// 日付が近い日から順番にメモを表示させます。 313 | DateTime get updatedAt; 314 | @override 315 | @JsonKey(ignore: true) 316 | _$$_TodoItemCopyWith<_$_TodoItem> get copyWith => 317 | throw _privateConstructorUsedError; 318 | } 319 | -------------------------------------------------------------------------------- /lib/features/todo/domain/todo_list/todo_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:freezed_annotation/freezed_annotation.dart'; 3 | import 'package:todo/constants.dart'; 4 | import 'package:todo/features/todo/domain/todo_item/todo_item.dart'; 5 | 6 | part 'todo_list.freezed.dart'; 7 | 8 | /// メモのリスト(DDDではファーストクラスコレクションに位置するクラス) 9 | /// 10 | /// ドメインに関するロジックはできる限り、ドメインクラスに記載すること。 11 | @freezed 12 | class TodoList with _$TodoList { 13 | // メソッドを追加する場合はプライベートコンストラクターを定義します。 14 | const TodoList._(); 15 | 16 | const factory TodoList({ 17 | /// メモのリスト 18 | required List items, 19 | 20 | /// ページングできるかどうかを示すフラグ 21 | /// 22 | /// これ以上ページングできない場合はtrueとなります。 23 | @Default(false) bool hasReachedMax, 24 | }) = _TodoList; 25 | 26 | TodoList fetch(List todoItemList) { 27 | // メモがまだ取得できるか(ページングできるか)どうかはここで判断しています。 28 | // メモの取得個数がページングできる個数に達しなかった場合は、これ以上取得できない状態です。 29 | final hasReachedMax = todoItemList.length < page; 30 | 31 | return copyWith( 32 | items: [...items, ...todoItemList], 33 | hasReachedMax: hasReachedMax, 34 | ); 35 | } 36 | 37 | int get length => items.length; 38 | 39 | // 更新日が近いものほどリストのTopにくるため、 40 | // add関数はリストの先頭に新しいメモを追加しています。 41 | // 通常のadd関数はリストの末尾に追加されるため、注意が必要です。 42 | TodoList add(TodoItem item) => copyWith(items: [item, ...items]); 43 | 44 | TodoList edit(TodoItem todoItem) { 45 | // idからリストのindexを調べます。 46 | final index = items.map((item) => item.id).toList().indexOf(todoItem.id); 47 | 48 | // 編集するとリストの先頭に編集されたメモが表示される必要があるので、insert関数を適用します。 49 | final editedItem = List.of(items) 50 | ..removeAt(index) 51 | ..insert(0, todoItem); 52 | 53 | return copyWith(items: editedItem); 54 | } 55 | 56 | TodoList remove(TodoItem todoItem) { 57 | // idからリストのindexを調べます。 58 | final index = items.map((item) => item.id).toList().indexOf(todoItem.id); 59 | final removedItem = List.of(items)..removeAt(index); 60 | 61 | return copyWith(items: removedItem); 62 | } 63 | 64 | /// undoの適用の際に使用します。 65 | TodoList insert(TodoItem todoItem, int index) { 66 | final insertedItem = List.of(items)..insert(index, todoItem); 67 | 68 | return copyWith(items: insertedItem); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/features/todo/domain/todo_list/todo_list.freezed.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | // GENERATED CODE - DO NOT MODIFY BY HAND 3 | // ignore_for_file: type=lint 4 | // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark 5 | 6 | part of 'todo_list.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | T _$identity(T value) => value; 13 | 14 | final _privateConstructorUsedError = UnsupportedError( 15 | 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 16 | 17 | /// @nodoc 18 | mixin _$TodoList { 19 | /// メモのリスト 20 | List get items => throw _privateConstructorUsedError; 21 | 22 | /// ページングできるかどうかを示すフラグ 23 | /// 24 | /// これ以上ページングできない場合はtrueとなります。 25 | bool get hasReachedMax => throw _privateConstructorUsedError; 26 | 27 | @JsonKey(ignore: true) 28 | $TodoListCopyWith get copyWith => 29 | throw _privateConstructorUsedError; 30 | } 31 | 32 | /// @nodoc 33 | abstract class $TodoListCopyWith<$Res> { 34 | factory $TodoListCopyWith(TodoList value, $Res Function(TodoList) then) = 35 | _$TodoListCopyWithImpl<$Res, TodoList>; 36 | @useResult 37 | $Res call({List items, bool hasReachedMax}); 38 | } 39 | 40 | /// @nodoc 41 | class _$TodoListCopyWithImpl<$Res, $Val extends TodoList> 42 | implements $TodoListCopyWith<$Res> { 43 | _$TodoListCopyWithImpl(this._value, this._then); 44 | 45 | // ignore: unused_field 46 | final $Val _value; 47 | // ignore: unused_field 48 | final $Res Function($Val) _then; 49 | 50 | @pragma('vm:prefer-inline') 51 | @override 52 | $Res call({ 53 | Object? items = null, 54 | Object? hasReachedMax = null, 55 | }) { 56 | return _then(_value.copyWith( 57 | items: null == items 58 | ? _value.items 59 | : items // ignore: cast_nullable_to_non_nullable 60 | as List, 61 | hasReachedMax: null == hasReachedMax 62 | ? _value.hasReachedMax 63 | : hasReachedMax // ignore: cast_nullable_to_non_nullable 64 | as bool, 65 | ) as $Val); 66 | } 67 | } 68 | 69 | /// @nodoc 70 | abstract class _$$_TodoListCopyWith<$Res> implements $TodoListCopyWith<$Res> { 71 | factory _$$_TodoListCopyWith( 72 | _$_TodoList value, $Res Function(_$_TodoList) then) = 73 | __$$_TodoListCopyWithImpl<$Res>; 74 | @override 75 | @useResult 76 | $Res call({List items, bool hasReachedMax}); 77 | } 78 | 79 | /// @nodoc 80 | class __$$_TodoListCopyWithImpl<$Res> 81 | extends _$TodoListCopyWithImpl<$Res, _$_TodoList> 82 | implements _$$_TodoListCopyWith<$Res> { 83 | __$$_TodoListCopyWithImpl( 84 | _$_TodoList _value, $Res Function(_$_TodoList) _then) 85 | : super(_value, _then); 86 | 87 | @pragma('vm:prefer-inline') 88 | @override 89 | $Res call({ 90 | Object? items = null, 91 | Object? hasReachedMax = null, 92 | }) { 93 | return _then(_$_TodoList( 94 | items: null == items 95 | ? _value._items 96 | : items // ignore: cast_nullable_to_non_nullable 97 | as List, 98 | hasReachedMax: null == hasReachedMax 99 | ? _value.hasReachedMax 100 | : hasReachedMax // ignore: cast_nullable_to_non_nullable 101 | as bool, 102 | )); 103 | } 104 | } 105 | 106 | /// @nodoc 107 | 108 | class _$_TodoList extends _TodoList with DiagnosticableTreeMixin { 109 | const _$_TodoList( 110 | {required final List items, this.hasReachedMax = false}) 111 | : _items = items, 112 | super._(); 113 | 114 | /// メモのリスト 115 | final List _items; 116 | 117 | /// メモのリスト 118 | @override 119 | List get items { 120 | if (_items is EqualUnmodifiableListView) return _items; 121 | // ignore: implicit_dynamic_type 122 | return EqualUnmodifiableListView(_items); 123 | } 124 | 125 | /// ページングできるかどうかを示すフラグ 126 | /// 127 | /// これ以上ページングできない場合はtrueとなります。 128 | @override 129 | @JsonKey() 130 | final bool hasReachedMax; 131 | 132 | @override 133 | String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { 134 | return 'TodoList(items: $items, hasReachedMax: $hasReachedMax)'; 135 | } 136 | 137 | @override 138 | void debugFillProperties(DiagnosticPropertiesBuilder properties) { 139 | super.debugFillProperties(properties); 140 | properties 141 | ..add(DiagnosticsProperty('type', 'TodoList')) 142 | ..add(DiagnosticsProperty('items', items)) 143 | ..add(DiagnosticsProperty('hasReachedMax', hasReachedMax)); 144 | } 145 | 146 | @override 147 | bool operator ==(dynamic other) { 148 | return identical(this, other) || 149 | (other.runtimeType == runtimeType && 150 | other is _$_TodoList && 151 | const DeepCollectionEquality().equals(other._items, _items) && 152 | (identical(other.hasReachedMax, hasReachedMax) || 153 | other.hasReachedMax == hasReachedMax)); 154 | } 155 | 156 | @override 157 | int get hashCode => Object.hash( 158 | runtimeType, const DeepCollectionEquality().hash(_items), hasReachedMax); 159 | 160 | @JsonKey(ignore: true) 161 | @override 162 | @pragma('vm:prefer-inline') 163 | _$$_TodoListCopyWith<_$_TodoList> get copyWith => 164 | __$$_TodoListCopyWithImpl<_$_TodoList>(this, _$identity); 165 | } 166 | 167 | abstract class _TodoList extends TodoList { 168 | const factory _TodoList( 169 | {required final List items, 170 | final bool hasReachedMax}) = _$_TodoList; 171 | const _TodoList._() : super._(); 172 | 173 | @override 174 | 175 | /// メモのリスト 176 | List get items; 177 | @override 178 | 179 | /// ページングできるかどうかを示すフラグ 180 | /// 181 | /// これ以上ページングできない場合はtrueとなります。 182 | bool get hasReachedMax; 183 | @override 184 | @JsonKey(ignore: true) 185 | _$$_TodoListCopyWith<_$_TodoList> get copyWith => 186 | throw _privateConstructorUsedError; 187 | } 188 | -------------------------------------------------------------------------------- /lib/features/todo/infrastructure/dto/todo_dto.dart: -------------------------------------------------------------------------------- 1 | import 'package:isar/isar.dart'; 2 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 3 | 4 | part 'todo_dto.g.dart'; 5 | 6 | /// Isar専用のDTO(Data Transfer Object) 7 | /// 8 | /// Isarはfreezedをサポートしていないため、DTOに変換しています。 9 | /// 10 | /// DTOはドメインへ変換も含めたデータ受け渡し専用のクラスと定義しています。 11 | @collection 12 | class TodoDto { 13 | TodoDto({ 14 | this.id, 15 | required this.title, 16 | required this.discription, 17 | required this.createAt, 18 | required this.isGarbage, 19 | required this.updatedAt, 20 | }); 21 | 22 | Id? id; 23 | 24 | final String title; 25 | 26 | final String discription; 27 | 28 | final DateTime createAt; 29 | 30 | // 通常のメモ表示とゴミ箱に入っているメモ表示の2通りがあるため、 31 | // 当フラグにindexをつけ、クエリのパフォーマンスをあげます。 32 | @Index() 33 | final bool isGarbage; 34 | 35 | // 日付の近い順にメモを表示する必要があるため、 36 | // 更新日にindexをつけ、クエリのパフォーマンスをあげます。 37 | @Index() 38 | final DateTime updatedAt; 39 | 40 | factory TodoDto.fromDomain(TodoItem item) => TodoDto( 41 | id: item.id, 42 | title: item.title, 43 | discription: item.discription, 44 | createAt: item.createAt, 45 | isGarbage: item.isGarbage, 46 | updatedAt: item.updatedAt, 47 | ); 48 | 49 | TodoItem toDomain() => TodoItem( 50 | id: id!, 51 | title: title, 52 | discription: discription, 53 | createAt: createAt, 54 | isGarbage: isGarbage, 55 | updatedAt: updatedAt, 56 | ); 57 | } 58 | -------------------------------------------------------------------------------- /lib/features/todo/infrastructure/todo_infrastructure_importer.dart: -------------------------------------------------------------------------------- 1 | /// importの数をできるかぎり減らすためにバレルファイルを作成していますが、 2 | /// 個人的にはあっても無くてもどちらでも良いと個人的には思います。 3 | 4 | export 'package:todo/features/todo/infrastructure/todo_repository.dart'; 5 | export 'package:todo/features/todo/infrastructure/dto/todo_dto.dart'; 6 | -------------------------------------------------------------------------------- /lib/features/todo/infrastructure/todo_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:isar/isar.dart'; 3 | import 'package:todo/constants.dart'; 4 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 5 | import 'package:todo/features/todo/infrastructure/dto/todo_dto.dart'; 6 | 7 | /// main.dartでoverrideを行います。 8 | /// 9 | /// Isar.open関数はFutureのため、main.dartにて初期化しています。 10 | final todoIsarProvider = Provider((ref) => throw UnimplementedError()); 11 | 12 | /// RepositoryProviderはUsecase層内のみで使用すること。 13 | final todoRepositoryProvider = 14 | Provider((ref) => TodoRepository(ref.watch(todoIsarProvider))); 15 | 16 | /// isarのクエリについては 17 | /// https://isar.dev/ja/queries.html 18 | /// を参照してください。 19 | 20 | class TodoRepository { 21 | TodoRepository(this._isar); 22 | final Isar _isar; 23 | 24 | /// page:取得するメモの個数 25 | /// 26 | /// offset:取得開始位置の指定(ページングに使用) 27 | /// 28 | /// [TodoList]のlengthがoffsetとなります。 29 | Future> fetchTodos(int page, int offset) async { 30 | final todoDtoCollection = _isar.todoDtos; 31 | final todoDtos = await todoDtoCollection 32 | .where(sort: Sort.desc) 33 | .anyUpdatedAt() 34 | .filter() 35 | .isGarbageEqualTo(false) 36 | .offset(offset) 37 | .limit(page) 38 | .findAll(); 39 | 40 | return todoDtos.map((dto) => dto.toDomain()).toList(); 41 | } 42 | 43 | Future> fetchGarbageTodos() async { 44 | final todoDtoCollection = _isar.todoDtos; 45 | final todoDtos = await todoDtoCollection 46 | .where(sort: Sort.desc) 47 | .anyUpdatedAt() 48 | .filter() 49 | .isGarbageEqualTo(true) 50 | .findAll(); 51 | 52 | return todoDtos.map((dto) => dto.toDomain()).toList(); 53 | } 54 | 55 | Future add(TodoDto dto) async { 56 | final todoDtoCollection = _isar.todoDtos; 57 | 58 | // WriteとReadをトランザクション内にて行っています。 59 | final todoItem = await _isar.writeTxn(() async { 60 | final id = await todoDtoCollection.put(dto); 61 | final todoItem = (await todoDtoCollection.get(id))!.toDomain(); 62 | 63 | return todoItem; 64 | }); 65 | 66 | return todoItem; 67 | } 68 | 69 | Future edit(TodoItem item) async { 70 | final todoDtoCollection = _isar.todoDtos; 71 | await _isar.writeTxn(() => todoDtoCollection.put(TodoDto.fromDomain(item))); 72 | 73 | return; 74 | } 75 | 76 | Future> fetchTodoListScheduledToDelete() async { 77 | final todoDtoCollection = _isar.todoDtos; 78 | final todoDtos = await todoDtoCollection 79 | .where() 80 | .updatedAtLessThan( 81 | DateTime.now().subtract(const Duration(days: deletedDurationDays)), 82 | ) 83 | .filter() 84 | .isGarbageEqualTo(true) 85 | .findAll(); 86 | 87 | return todoDtos.map((dto) => dto.toDomain()).toList(); 88 | } 89 | 90 | Future deleteAll(List todoList) async { 91 | final todoDtoCollection = _isar.todoDtos; 92 | await _isar.writeTxn(() => 93 | todoDtoCollection.deleteAll(todoList.map((item) => item.id).toList())); 94 | 95 | return; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/create_or_edit_todo/create_or_edit_todo_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 5 | import 'package:todo/features/todo/presentation/todo_list_notifier.dart'; 6 | import 'package:todo/theme.dart'; 7 | 8 | /// メモの編集の場合はメモのタイトルの初期値が存在するので、familyを付与しています。 9 | /// このファイル内でのみしか使用しないため、アンダースコアを付けるようにしてください。 10 | final _textEditingControllerProvider = 11 | Provider.autoDispose.family((ref, text) { 12 | final controller = TextEditingController(text: text); 13 | ref.onDispose(() { 14 | controller.dispose(); 15 | }); 16 | 17 | return controller; 18 | }); 19 | 20 | /// メモの編集の場合はメモ内容の初期値が存在するので、familyを付与しています。 21 | /// このファイル内でのみしか使用しないため、アンダースコアを付けるようにしてください。 22 | final _discriptionEditingControllerProvider = 23 | Provider.autoDispose.family((ref, text) { 24 | final controller = TextEditingController(text: text); 25 | ref.onDispose(() { 26 | controller.dispose(); 27 | }); 28 | 29 | return controller; 30 | }); 31 | 32 | class CreateOrEditTodoPage extends ConsumerWidget { 33 | const CreateOrEditTodoPage({ 34 | super.key, 35 | this.item, 36 | }); 37 | 38 | /// 新しくtodoを作成する場合はnullを渡します。 39 | /// 40 | /// 編集の場合は、編集したい[TodoItem]を渡します。 41 | final TodoItem? item; 42 | 43 | Future _save({ 44 | required WidgetRef ref, 45 | required String title, 46 | required String discription, 47 | }) async { 48 | if (item?.isGarbage == true) return; 49 | 50 | // 全く記入していない場合は保存しませんが、 51 | // タイトルか内容どちらかが記入されていれば保存されるようにしています。 52 | if (title.isEmpty && discription.isEmpty) { 53 | return; 54 | } 55 | final asyncNotifier = ref.read(todoListAsyncNotifierProvider.notifier); 56 | 57 | // データベースにメモの保存を行います。 58 | // この時、エラーが発生するとViewStateはAsyncErrorとなります。 59 | if (item == null) { 60 | await asyncNotifier.addTodoItem( 61 | title: title, 62 | discription: discription, 63 | ); 64 | } else { 65 | if (title == item!.title && discription == item!.discription) { 66 | return; 67 | } 68 | await asyncNotifier.editTodoItem( 69 | title: title, 70 | discription: discription, 71 | item: item!, 72 | ); 73 | } 74 | } 75 | 76 | @override 77 | Widget build(BuildContext context, WidgetRef ref) { 78 | final titleEditingController = 79 | ref.watch(_textEditingControllerProvider(item?.title ?? '')); 80 | 81 | final discriptionEditingController = ref 82 | .watch(_discriptionEditingControllerProvider(item?.discription ?? '')); 83 | 84 | return Scaffold( 85 | appBar: AppBar( 86 | actions: [ 87 | IconButton( 88 | onPressed: () async { 89 | await _save( 90 | ref: ref, 91 | title: titleEditingController.text, 92 | discription: discriptionEditingController.text, 93 | ); 94 | // エラーが生じた場合はダイアログを出すため、 95 | // 画面遷移をさせないよう早期リターンを行っています。 96 | if (ref.read(todoListAsyncNotifierProvider) is AsyncError) return; 97 | context.pop(); 98 | }, 99 | icon: const Icon(Icons.save), 100 | ), 101 | ], 102 | ), 103 | body: SingleChildScrollView( 104 | child: Padding( 105 | padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15), 106 | child: Column( 107 | children: [ 108 | TextFormField( 109 | readOnly: item?.isGarbage == true, 110 | controller: titleEditingController, 111 | style: const TextStyle( 112 | fontSize: 18, 113 | fontWeight: FontWeight.w600, 114 | ), 115 | maxLines: null, 116 | keyboardType: TextInputType.multiline, 117 | decoration: const InputDecoration( 118 | border: InputBorder.none, 119 | hintText: 'タイトル', 120 | hintStyle: TextStyle( 121 | color: AppColor.greyTextColor, 122 | fontSize: 18, 123 | fontWeight: FontWeight.w600, 124 | ), 125 | ), 126 | ), 127 | const SizedBox(height: 30), 128 | TextFormField( 129 | readOnly: item?.isGarbage == true, 130 | controller: discriptionEditingController, 131 | style: const TextStyle( 132 | fontSize: 16, 133 | fontWeight: FontWeight.w300, 134 | ), 135 | maxLines: null, 136 | keyboardType: TextInputType.multiline, 137 | decoration: const InputDecoration( 138 | border: InputBorder.none, 139 | hintText: '本文を記入してください', 140 | hintStyle: TextStyle( 141 | color: AppColor.greyTextColor, 142 | fontSize: 16, 143 | fontWeight: FontWeight.w300, 144 | ), 145 | ), 146 | ), 147 | ], 148 | ), 149 | ), 150 | ), 151 | ); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/garbage_todo_list/garbage_todo_list_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/presentation/todo_list_notifier.dart'; 5 | import 'package:todo/features/todo/usecase/change_to_garbage_status_usecase.dart'; 6 | import 'package:todo/features/todo/usecase/todo_usecase_importer.dart'; 7 | 8 | /// GarbageTodoListPageでのみ使用するProvider 9 | final garbageTodoListAsyncNotifierProvider = 10 | AsyncNotifierProvider.autoDispose( 11 | GarbageTodoListNotifier.new, 12 | ); 13 | 14 | class GarbageTodoListNotifier extends AutoDisposeAsyncNotifier { 15 | @override 16 | FutureOr build() async { 17 | const todoList = TodoList(items: []); 18 | 19 | // 90日間ゴミ箱に存在しているメモはローカルから削除します。 20 | await ref.read(deleteTodosUsecaseProvider)(); 21 | final todoItemList = await ref.read(fetchGarbageTodosUsecaseProvider)(); 22 | 23 | return todoList.fetch(todoItemList); 24 | } 25 | 26 | Future returnFromTrash(TodoItem item) async { 27 | state = await AsyncValue.guard(() async { 28 | final todoItem = await ref.read(changeToGarbageStatusUsecaseProvider)( 29 | item: item, 30 | toGabage: false, 31 | isUndoing: false, 32 | ); 33 | 34 | return state.value!.remove(todoItem); 35 | }); 36 | 37 | // 変更の結果をTodoListPageに反映しておく必要があるので、providerをリフレッシュします。 38 | ref.invalidate(todoListAsyncNotifierProvider); 39 | } 40 | 41 | Future undoToReturnFromTrash(TodoItem item, int index) async { 42 | state = await AsyncValue.guard(() async { 43 | final todoItem = await ref.read(changeToGarbageStatusUsecaseProvider)( 44 | item: item, 45 | toGabage: true, 46 | isUndoing: true, 47 | ); 48 | 49 | return state.value!.insert(todoItem, index); 50 | }); 51 | 52 | // 変更の結果をTodoListPageに反映しておく必要があるので、providerをリフレッシュします。 53 | ref.invalidate(todoListAsyncNotifierProvider); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/garbage_todo_list/garbage_todo_list_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:logger/logger.dart'; 4 | import 'package:todo/features/todo/presentation/garbage_todo_list/garbage_todo_list_notifier.dart'; 5 | import 'package:todo/features/todo/presentation/todo_presentation_importer.dart'; 6 | import 'package:todo/features/todo/presentation/widgets/snack_bar.dart'; 7 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 8 | import 'package:todo/theme.dart'; 9 | 10 | class GarbageTodoListPage extends ConsumerWidget { 11 | const GarbageTodoListPage({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final asyncValue = ref.watch(garbageTodoListAsyncNotifierProvider); 16 | final notifier = ref.watch(garbageTodoListAsyncNotifierProvider.notifier); 17 | 18 | // AsyncErrorの場合はSnackBarを表示させることで、ユーザーにエラー状態を伝えることができます。 19 | // ユーザーへのメッセージはUsecase層にて定義しています。 20 | ref.listen(garbageTodoListAsyncNotifierProvider, (previous, next) { 21 | if (next is AsyncError) { 22 | ScaffoldMessenger.of(context).showSnackBar(CustomErrorSnackBar( 23 | message: (next.error! as CustomException).message, 24 | )); 25 | } 26 | }); 27 | 28 | return Scaffold( 29 | appBar: AppBar( 30 | backgroundColor: AppColor.greyColor, 31 | title: const Text( 32 | 'ゴミ箱', 33 | style: TextStyle(fontSize: 16), 34 | ), 35 | ), 36 | body: Column( 37 | crossAxisAlignment: CrossAxisAlignment.start, 38 | children: [ 39 | Padding( 40 | padding: const EdgeInsets.symmetric(horizontal: 30), 41 | child: Column( 42 | crossAxisAlignment: CrossAxisAlignment.start, 43 | children: const [ 44 | SizedBox(height: 25), 45 | Text( 46 | '90日経過すると完全に削除されます。', 47 | style: TextStyle( 48 | fontSize: 14, 49 | color: AppColor.paleTextColor, 50 | fontWeight: FontWeight.w600, 51 | ), 52 | ), 53 | SizedBox(height: 7), 54 | Text( 55 | '復元したい時は、⇨右にスワイプして下さい。', 56 | style: TextStyle( 57 | fontSize: 14, 58 | color: AppColor.paleTextColor, 59 | ), 60 | ), 61 | ], 62 | ), 63 | ), 64 | Expanded( 65 | child: asyncValue.when( 66 | skipError: true, 67 | error: (e, st) { 68 | Logger().e('_garbageTodoListProviderにエラー発生', e, st); 69 | 70 | return const Center(child: Text('データベースエラー')); 71 | }, 72 | loading: () => const Center(child: CircularProgressIndicator()), 73 | data: (garbageTodoList) { 74 | return RefreshIndicator( 75 | onRefresh: () async => 76 | ref.invalidate(garbageTodoListAsyncNotifierProvider), 77 | child: Padding( 78 | padding: const EdgeInsets.symmetric(vertical: 10), 79 | child: ListView.builder( 80 | itemCount: garbageTodoList.length, 81 | itemBuilder: (context, index) { 82 | final item = garbageTodoList.items[index]; 83 | 84 | return Dismissible( 85 | key: Key(item.id.toString()), 86 | direction: DismissDirection.startToEnd, 87 | onDismissed: (direction) async { 88 | await notifier.returnFromTrash(item); 89 | 90 | ScaffoldMessenger.of(context) 91 | .showSnackBar(CustomSnackBar( 92 | message: 'メモをゴミ箱から戻しました', 93 | undoLabel: '取消', 94 | onUndid: () => 95 | notifier.undoToReturnFromTrash(item, index), 96 | )); 97 | }, 98 | child: TodoCard( 99 | todoItem: item, 100 | ), 101 | ); 102 | }, 103 | ), 104 | ), 105 | ); 106 | }, 107 | ), 108 | ), 109 | ], 110 | ), 111 | ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/todo_list/todo_list_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:logger/logger.dart'; 5 | import 'package:todo/features/todo/presentation/widgets/snack_bar.dart'; 6 | import 'package:todo/features/todo/presentation/widgets/todo_card.dart'; 7 | import 'package:todo/features/todo/presentation/todo_list/widgets/todo_drawer.dart'; 8 | import 'package:todo/features/todo/presentation/todo_list_notifier.dart'; 9 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 10 | 11 | final _scrollControllerProvider = Provider.autoDispose( 12 | (ref) { 13 | final controller = ScrollController(); 14 | ref.onDispose(() { 15 | controller.dispose(); 16 | }); 17 | 18 | controller.addListener(() { 19 | final todoList = ref.read(todoListAsyncNotifierProvider).value; 20 | if (todoList?.hasReachedMax != false) return; 21 | 22 | const threshold = 0.8; 23 | // 現在のスクロールしている割合(0:上端、1:末端) 24 | final scrollRatio = 25 | controller.offset / controller.position.maxScrollExtent; 26 | if (scrollRatio < threshold) return; 27 | ref.read(todoListAsyncNotifierProvider.notifier).fetchMore(); 28 | }); 29 | 30 | return controller; 31 | }, 32 | ); 33 | 34 | class TodoListPage extends ConsumerWidget { 35 | const TodoListPage({super.key}); 36 | 37 | @override 38 | Widget build(BuildContext context, WidgetRef ref) { 39 | final asyncValue = ref.watch(todoListAsyncNotifierProvider); 40 | final notifier = ref.watch(todoListAsyncNotifierProvider.notifier); 41 | 42 | // AsyncErrorの場合はSnackBarを表示させることで、ユーザーにエラー状態を伝えることができます。 43 | // ユーザーへのメッセージはUsecase層にて定義しています。 44 | ref.listen(todoListAsyncNotifierProvider, (previous, next) { 45 | if (next is AsyncError) { 46 | ScaffoldMessenger.of(context).showSnackBar(CustomErrorSnackBar( 47 | message: (next.error! as CustomException).message, 48 | )); 49 | } 50 | }); 51 | 52 | return Scaffold( 53 | appBar: AppBar(), 54 | floatingActionButton: FloatingActionButton( 55 | onPressed: () => context.push('/create'), 56 | child: const Icon(Icons.edit), 57 | ), 58 | drawer: const TodoDrawer(), 59 | body: asyncValue.when( 60 | skipError: true, 61 | error: (e, st) { 62 | Logger().e('todoListAsyncNotifierにエラー発生', e, st); 63 | 64 | return const Center(child: Text('データベースエラー')); 65 | }, 66 | loading: () => const Center(child: CircularProgressIndicator()), 67 | data: (todoList) { 68 | return Column( 69 | children: [ 70 | Expanded( 71 | child: RefreshIndicator( 72 | onRefresh: () async => 73 | ref.invalidate(todoListAsyncNotifierProvider), 74 | child: Padding( 75 | padding: const EdgeInsets.symmetric(vertical: 10), 76 | child: ListView.builder( 77 | controller: ref.watch(_scrollControllerProvider), 78 | itemCount: todoList.length, 79 | itemBuilder: (context, index) { 80 | final item = todoList.items[index]; 81 | 82 | return Dismissible( 83 | key: Key(item.id.toString()), 84 | direction: DismissDirection.startToEnd, 85 | onDismissed: (direction) async { 86 | await notifier.putInTrash(item); 87 | 88 | ScaffoldMessenger.of(context) 89 | .showSnackBar(CustomSnackBar( 90 | message: 'メモをゴミ箱に入れました', 91 | undoLabel: '取消', 92 | onUndid: () => 93 | notifier.undoToPutInTrash(item, index), 94 | )); 95 | }, 96 | child: TodoCard(todoItem: item), 97 | ); 98 | }, 99 | ), 100 | ), 101 | ), 102 | ), 103 | if (asyncValue.isLoading) 104 | const Padding( 105 | padding: EdgeInsets.symmetric(vertical: 10), 106 | child: Center(child: CircularProgressIndicator()), 107 | ), 108 | ], 109 | ); 110 | }, 111 | ), 112 | ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/todo_list/widgets/todo_drawer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:todo/theme.dart'; 4 | 5 | class TodoDrawer extends StatelessWidget { 6 | const TodoDrawer({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Drawer( 11 | child: Padding( 12 | padding: const EdgeInsets.only(top: 80, left: 15, right: 15), 13 | child: ListView( 14 | physics: const ClampingScrollPhysics(), 15 | children: [ 16 | Row( 17 | children: [ 18 | const Spacer(), 19 | IconButton( 20 | onPressed: () => Navigator.of(context).pop(), 21 | icon: const Icon( 22 | Icons.cancel, 23 | color: AppColor.greyColor, 24 | size: 30, 25 | ), 26 | ), 27 | ], 28 | ), 29 | const SizedBox(height: 10), 30 | _DrawerListTile( 31 | iconData: Icons.delete, 32 | title: 'ゴミ箱', 33 | onPressed: () { 34 | Navigator.of(context).pop(); 35 | context.push('/garbage'); 36 | }, 37 | ), 38 | ], 39 | ), 40 | ), 41 | ); 42 | } 43 | } 44 | 45 | class _DrawerListTile extends StatelessWidget { 46 | const _DrawerListTile({ 47 | required this.iconData, 48 | required this.title, 49 | required this.onPressed, 50 | }); 51 | 52 | final IconData iconData; 53 | final String title; 54 | final void Function() onPressed; 55 | 56 | @override 57 | Widget build(BuildContext context) { 58 | return GestureDetector( 59 | onTap: onPressed, 60 | child: Container( 61 | padding: const EdgeInsets.only(left: 13, right: 25), 62 | height: 65, 63 | decoration: BoxDecoration( 64 | color: Colors.white, 65 | borderRadius: BorderRadius.circular(10), 66 | ), 67 | child: Row( 68 | children: [ 69 | Icon(iconData), 70 | const SizedBox(width: 8), 71 | Text( 72 | title, 73 | style: const TextStyle( 74 | fontSize: 16, 75 | fontWeight: FontWeight.w600, 76 | ), 77 | ), 78 | const Spacer(), 79 | const Icon(Icons.navigate_next), 80 | ], 81 | ), 82 | ), 83 | ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/todo_list_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/usecase/change_to_garbage_status_usecase.dart'; 5 | import 'package:todo/features/todo/usecase/todo_usecase_importer.dart'; 6 | 7 | /// グローバルで使用するプロバイダー 8 | /// 9 | /// Riverpodを使用すれば、いくらでもグローバルな変数を定義できますが、 10 | /// できるかぎりグローバル変数を多く作らないことが重要です。 11 | 12 | final todoListAsyncNotifierProvider = 13 | AsyncNotifierProvider.autoDispose( 14 | TodoListNotifier.new, 15 | ); 16 | 17 | class TodoListNotifier extends AutoDisposeAsyncNotifier { 18 | @override 19 | FutureOr build() async { 20 | const todoList = TodoList(items: []); 21 | final todoItemList = await ref.read(fetchTodosUsecaseProvider)(offset: 0); 22 | 23 | return todoList.fetch(todoItemList); 24 | } 25 | 26 | Future fetchMore() async { 27 | // 取得済みのデータを保持しながら状態をローディング中にします。 28 | state = const AsyncValue.loading().copyWithPrevious(state); 29 | state = await AsyncValue.guard(() async { 30 | final fetchedTodoList = await ref.read(fetchTodosUsecaseProvider)( 31 | offset: state.value!.length, 32 | ); 33 | 34 | return state.value!.fetch(fetchedTodoList); 35 | }); 36 | } 37 | 38 | Future addTodoItem({ 39 | required String title, 40 | required String discription, 41 | }) async { 42 | state = await AsyncValue.guard(() async { 43 | final todoItem = await ref.read(addTodoUsecaseProvider)( 44 | title: title, 45 | discription: discription, 46 | ); 47 | 48 | return state.value!.add(todoItem); 49 | }); 50 | } 51 | 52 | Future editTodoItem({ 53 | required String title, 54 | required String discription, 55 | required TodoItem item, 56 | }) async { 57 | state = await AsyncValue.guard(() async { 58 | final todoItem = await ref.read(editTodoUsecaseProvider)( 59 | title: title, 60 | discription: discription, 61 | item: item, 62 | ); 63 | 64 | return state.value!.edit(todoItem); 65 | }); 66 | } 67 | 68 | Future putInTrash(TodoItem item) async { 69 | state = await AsyncValue.guard(() async { 70 | final todoItem = await ref.read(changeToGarbageStatusUsecaseProvider)( 71 | item: item, 72 | toGabage: true, 73 | isUndoing: false, 74 | ); 75 | 76 | return state.value!.remove(todoItem); 77 | }); 78 | } 79 | 80 | Future undoToPutInTrash(TodoItem item, int index) async { 81 | state = await AsyncValue.guard(() async { 82 | final todoItem = await ref.read(changeToGarbageStatusUsecaseProvider)( 83 | item: item, 84 | toGabage: false, 85 | isUndoing: true, 86 | ); 87 | 88 | return state.value!.insert(todoItem, index); 89 | }); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/todo_presentation_importer.dart: -------------------------------------------------------------------------------- 1 | /// importの数をできるかぎり減らすためにバレルファイルを作成していますが、 2 | /// 個人的にはあっても無くてもどちらでも良いと個人的には思います。 3 | 4 | export 'package:todo/features/todo/presentation/widgets/todo_card.dart'; 5 | export 'package:todo/features/todo/presentation/create_or_edit_todo/create_or_edit_todo_page.dart'; 6 | export 'package:todo/features/todo/presentation/todo_list/todo_list_page.dart'; 7 | export 'package:todo/features/todo/presentation/garbage_todo_list/garbage_todo_list_page.dart'; 8 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/widgets/snack_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CustomSnackBar extends SnackBar { 4 | CustomSnackBar({ 5 | super.key, 6 | required this.message, 7 | required this.undoLabel, 8 | required this.onUndid, 9 | }) : super( 10 | content: Text(message), 11 | action: SnackBarAction( 12 | label: undoLabel, 13 | onPressed: onUndid, 14 | ), 15 | duration: const Duration(seconds: 1), 16 | ); 17 | 18 | final String message; 19 | final String undoLabel; 20 | final void Function() onUndid; 21 | } 22 | 23 | class CustomErrorSnackBar extends SnackBar { 24 | CustomErrorSnackBar({super.key, required this.message}) 25 | : super( 26 | content: Text(message), 27 | duration: const Duration(seconds: 1), 28 | ); 29 | 30 | final String message; 31 | } 32 | -------------------------------------------------------------------------------- /lib/features/todo/presentation/widgets/todo_card.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/theme.dart'; 5 | 6 | class TodoCard extends StatelessWidget { 7 | const TodoCard({ 8 | super.key, 9 | required this.todoItem, 10 | }); 11 | 12 | final TodoItem todoItem; 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return GestureDetector( 17 | onTap: () => context.push('/todo/${todoItem.id}', extra: todoItem), 18 | child: Container( 19 | margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), 20 | padding: 21 | const EdgeInsets.only(top: 16, bottom: 18, left: 15, right: 15), 22 | decoration: BoxDecoration( 23 | borderRadius: BorderRadius.circular(14), 24 | color: Colors.white, 25 | ), 26 | child: Column( 27 | crossAxisAlignment: CrossAxisAlignment.start, 28 | children: [ 29 | Text( 30 | todoItem.isEmptyTitle ? 'タイトル未記入' : todoItem.title, 31 | style: TextStyle( 32 | fontSize: 15, 33 | fontWeight: FontWeight.w600, 34 | color: todoItem.isEmptyTitle ? AppColor.paleTextColor : null, 35 | ), 36 | overflow: TextOverflow.clip, 37 | ), 38 | const SizedBox(height: 3), 39 | Text( 40 | todoItem.discription, 41 | style: const TextStyle( 42 | fontSize: 16, 43 | fontWeight: FontWeight.w300, 44 | ), 45 | overflow: TextOverflow.clip, 46 | ), 47 | const SizedBox(height: 17), 48 | Text( 49 | todoItem.updatedAtText, 50 | style: const TextStyle( 51 | fontSize: 12, 52 | color: AppColor.paleTextColor, 53 | ), 54 | ), 55 | ], 56 | ), 57 | ), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/add_todo_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:logger/logger.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/infrastructure/todo_infrastructure_importer.dart'; 5 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 6 | 7 | /// UsecaseはPresentation層のみで使用すること 8 | final addTodoUsecaseProvider = Provider.autoDispose((ref) { 9 | return AddTodoUsecase(ref.watch(todoRepositoryProvider)); 10 | }); 11 | 12 | /// メモを追加するロジック並びにエラー処理を行います。 13 | /// 14 | /// あくまでアプリケーション特有の処理を行うところであり、 15 | /// ドメイン由来のロジックはドメインクラスに記載することが重要です。 16 | class AddTodoUsecase { 17 | AddTodoUsecase(this._repository); 18 | final TodoRepository _repository; 19 | 20 | Future call({ 21 | required String title, 22 | required String discription, 23 | }) async { 24 | try { 25 | final now = DateTime.now(); 26 | final todoDto = TodoDto( 27 | title: title, 28 | discription: discription, 29 | createAt: now, 30 | isGarbage: false, 31 | updatedAt: now, 32 | ); 33 | final todoItem = await _repository.add(todoDto); 34 | 35 | return todoItem; 36 | } catch (e, st) { 37 | Logger().e('AddTodoUsecaseでのエラー', e, st); 38 | throw CustomException('メモを保存できませんでした。'); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/change_to_garbage_status_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:logger/logger.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/infrastructure/todo_infrastructure_importer.dart'; 5 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 6 | 7 | /// UsecaseはPresentation層のみで使用すること 8 | final changeToGarbageStatusUsecaseProvider = 9 | Provider.autoDispose((ref) { 10 | return ChangeToGarbageStatusUsecase(ref.watch(todoRepositoryProvider)); 11 | }); 12 | 13 | /// ゴミ箱に入れるか元に戻すかのロジック並びにエラー処理を行います。 14 | /// 15 | /// あくまでアプリケーション特有の処理を行うところであり、 16 | /// ドメイン由来のロジックはドメインクラスに記載することが重要です。 17 | class ChangeToGarbageStatusUsecase { 18 | ChangeToGarbageStatusUsecase(this._repository); 19 | final TodoRepository _repository; 20 | 21 | Future call({ 22 | required TodoItem item, 23 | required bool toGabage, 24 | required bool isUndoing, 25 | }) async { 26 | try { 27 | // 取消処理の場合は更新日を元の更新日にしておく必要があるため、updateDateTime関数を適用せず、 28 | // 取消以外の場合は更新日を最新にします。 29 | final garbageTodoItem = isUndoing 30 | ? item.toGarbage(toGabage: toGabage) 31 | : item.toGarbage(toGabage: toGabage).updateDateTime(); 32 | 33 | await _repository.edit(garbageTodoItem); 34 | 35 | return garbageTodoItem; 36 | } catch (e, st) { 37 | Logger().e('ChangeToGarbageStatusUsecaseでのエラー', e, st); 38 | throw CustomException('メモのゴミ状態を変更できませんでした。'); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/custom_exception.dart: -------------------------------------------------------------------------------- 1 | /// coreやutilなどのフォルダを作成し、そこにexceptionに関するファイルを格納した方が良いです。 2 | /// 今回は単純なアプリなので、エラー処理を行っているUsecase層に定義しています。 3 | class CustomException implements Exception { 4 | final String message; 5 | 6 | CustomException(this.message); 7 | } 8 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/delete_todos_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:logger/logger.dart'; 3 | import 'package:todo/features/todo/infrastructure/todo_infrastructure_importer.dart'; 4 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 5 | 6 | /// UsecaseはPresentation層のみで使用すること 7 | final deleteTodosUsecaseProvider = 8 | Provider.autoDispose((ref) { 9 | return DeleteTodosUsecase(ref.watch(todoRepositoryProvider)); 10 | }); 11 | 12 | /// ゴミ箱に入っているメモを削除するロジック並びにエラー処理を行います。 13 | /// 14 | /// あくまでアプリケーション特有の処理を行うところであり、 15 | /// ドメイン由来のロジックはドメインクラスに記載することが重要です。 16 | class DeleteTodosUsecase { 17 | DeleteTodosUsecase(this._repository); 18 | final TodoRepository _repository; 19 | 20 | Future call() async { 21 | try { 22 | final deletedTodoItemList = 23 | await _repository.fetchTodoListScheduledToDelete(); 24 | await _repository.deleteAll(deletedTodoItemList); 25 | 26 | return; 27 | } catch (e, st) { 28 | Logger().e('DeleteTodosUsecaseでのエラー', e, st); 29 | throw CustomException('メモをローカルから削除できませんでした。'); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/edit_todo_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:logger/logger.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/infrastructure/todo_infrastructure_importer.dart'; 5 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 6 | 7 | /// UsecaseはPresentation層のみで使用すること 8 | final editTodoUsecaseProvider = Provider.autoDispose((ref) { 9 | return EditTodoUsecase(ref.watch(todoRepositoryProvider)); 10 | }); 11 | 12 | /// メモを編集するロジック並びにエラー処理を行います。 13 | /// 14 | /// あくまでアプリケーション特有の処理を行うところであり、 15 | /// ドメイン由来のロジックはドメインクラスに記載することが重要です。 16 | class EditTodoUsecase { 17 | EditTodoUsecase(this._repository); 18 | final TodoRepository _repository; 19 | 20 | Future call({ 21 | required String title, 22 | required String discription, 23 | required TodoItem item, 24 | }) async { 25 | try { 26 | final updatedTodoItem = item.update( 27 | title: title, 28 | discription: discription, 29 | ); 30 | await _repository.edit(updatedTodoItem); 31 | 32 | return updatedTodoItem; 33 | } catch (e, st) { 34 | Logger().e('EditTodoUsecaseでのエラー', e, st); 35 | throw CustomException('メモを編集できませんでした。'); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/fetch_garbage_todos_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:logger/logger.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/infrastructure/todo_infrastructure_importer.dart'; 5 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 6 | 7 | /// UsecaseはPresentation層のみで使用すること 8 | final fetchGarbageTodosUsecaseProvider = 9 | Provider.autoDispose((ref) { 10 | return FetchGarbageTodosUsecase(ref.watch(todoRepositoryProvider)); 11 | }); 12 | 13 | /// ゴミ箱に入っているメモの取得を行うロジック並びにエラー処理を行います。 14 | /// 15 | /// あくまでアプリケーション特有の処理を行うところであり、 16 | /// ドメイン由来のロジックはドメインクラスに記載することが重要です。 17 | class FetchGarbageTodosUsecase { 18 | FetchGarbageTodosUsecase(this._repository); 19 | final TodoRepository _repository; 20 | 21 | Future> call() async { 22 | try { 23 | final todoItemList = await _repository.fetchGarbageTodos(); 24 | 25 | return todoItemList; 26 | } catch (e, st) { 27 | Logger().e('FetchDeletedTodosUsecaseでのエラー', e, st); 28 | throw CustomException('ゴミ箱に存在するメモを取得できませんでした。'); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/fetch_todos_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:logger/logger.dart'; 3 | import 'package:todo/constants.dart'; 4 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 5 | import 'package:todo/features/todo/infrastructure/todo_infrastructure_importer.dart'; 6 | import 'package:todo/features/todo/usecase/custom_exception.dart'; 7 | 8 | /// UsecaseはPresentation層のみで使用すること 9 | final fetchTodosUsecaseProvider = 10 | Provider.autoDispose((ref) { 11 | return FetchTodosUsecase(ref.watch(todoRepositoryProvider)); 12 | }); 13 | 14 | /// メモの取得を行うロジック並びにエラー処理を行います。 15 | /// 16 | /// あくまでアプリケーション特有の処理を行うところであり、 17 | /// ドメイン由来のロジックはドメインクラスに記載することが重要です。 18 | class FetchTodosUsecase { 19 | FetchTodosUsecase(this._repository); 20 | final TodoRepository _repository; 21 | 22 | Future> call({required int offset}) async { 23 | try { 24 | final todoItemList = await _repository.fetchTodos(page, offset); 25 | 26 | return todoItemList; 27 | } catch (e, st) { 28 | Logger().e('FetchTodosUsecaseでのエラー', e, st); 29 | throw CustomException('メモを取得できませんでした。'); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/features/todo/usecase/todo_usecase_importer.dart: -------------------------------------------------------------------------------- 1 | /// importの数をできるかぎり減らすためにバレルファイルを作成していますが、 2 | /// 個人的にはあっても無くてもどちらでも良いと個人的には思います。 3 | 4 | export 'package:todo/features/todo/usecase/add_todo_usecase.dart'; 5 | export 'package:todo/features/todo/usecase/delete_todos_usecase.dart'; 6 | export 'package:todo/features/todo/usecase/edit_todo_usecase.dart'; 7 | export 'package:todo/features/todo/usecase/fetch_garbage_todos_usecase.dart'; 8 | export 'package:todo/features/todo/usecase/fetch_todos_usecase.dart'; 9 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_localizations/flutter_localizations.dart'; 3 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 4 | import 'package:isar/isar.dart'; 5 | import 'package:todo/features/todo/infrastructure/dto/todo_dto.dart'; 6 | import 'package:todo/features/todo/infrastructure/todo_repository.dart'; 7 | import 'package:todo/router.dart'; 8 | import 'package:todo/theme.dart'; 9 | 10 | Future main() async { 11 | final todoIsar = await Isar.open([TodoDtoSchema]); 12 | runApp(ProviderScope( 13 | overrides: [todoIsarProvider.overrideWithValue(todoIsar)], 14 | child: const MyApp(), 15 | )); 16 | } 17 | 18 | class MyApp extends ConsumerWidget { 19 | const MyApp({super.key}); 20 | 21 | // This widget is the root of your application. 22 | @override 23 | Widget build(BuildContext context, WidgetRef ref) { 24 | const locale = Locale("ja", "JP"); 25 | 26 | return MaterialApp.router( 27 | routerConfig: ref.watch(routerProvider), 28 | theme: ref.watch(themeProvider), 29 | locale: locale, 30 | localizationsDelegates: const [ 31 | GlobalMaterialLocalizations.delegate, 32 | GlobalWidgetsLocalizations.delegate, 33 | GlobalCupertinoLocalizations.delegate, 34 | ], 35 | supportedLocales: const [ 36 | locale, 37 | ], 38 | debugShowCheckedModeBanner: false, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/router.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:todo/features/todo/domain/todo_domain_importer.dart'; 4 | import 'package:todo/features/todo/presentation/todo_presentation_importer.dart'; 5 | 6 | final routerProvider = Provider((ref) { 7 | return _router; 8 | }); 9 | 10 | final _router = GoRouter( 11 | routes: [ 12 | GoRoute( 13 | path: '/', 14 | builder: (context, state) => const TodoListPage(), 15 | ), 16 | GoRoute( 17 | path: '/create', 18 | builder: (context, state) => const CreateOrEditTodoPage(), 19 | ), 20 | GoRoute( 21 | path: '/todo/:id', 22 | builder: (context, state) => 23 | CreateOrEditTodoPage(item: state.extra! as TodoItem), 24 | ), 25 | GoRoute( 26 | path: '/garbage', 27 | builder: (context, state) => const GarbageTodoListPage(), 28 | ), 29 | ], 30 | ); 31 | -------------------------------------------------------------------------------- /lib/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | final themeProvider = Provider((ref) { 5 | return _theme; 6 | }); 7 | 8 | /// このアプリ全体に適用させるカラーとテキストスタイルを規定します。 9 | final _theme = ThemeData.from(colorScheme: _colorScheme, textTheme: _textTheme); 10 | 11 | /// プロパティで表示されている12個のカラーの詳細はURLを参照してください。 12 | /// 13 | /// https://m2.material.io/design/material-theming/implementing-your-theme.html#color 14 | const _colorScheme = ColorScheme( 15 | brightness: Brightness.light, 16 | primary: AppColor.baseColor, 17 | onPrimary: Colors.white, 18 | secondary: AppColor.baseColor, 19 | onSecondary: Colors.white, 20 | error: Color(0xffE80000), 21 | onError: Colors.white, 22 | background: AppColor.backgroundColor, 23 | onBackground: Color(0xff2D2D2D), 24 | surface: Colors.white, 25 | onSurface: Color(0xff2D2D2D), 26 | ); 27 | 28 | /// テキストスタイルについての詳細はURLを参照してください。 29 | /// 30 | /// https://m2.material.io/design/material-theming/implementing-your-theme.html#typography 31 | final _textTheme = const TextTheme().apply( 32 | displayColor: AppColor.baseTextColor, 33 | bodyColor: AppColor.baseTextColor, 34 | ); 35 | 36 | /// このアプリで使用するカラーの種類 37 | class AppColor { 38 | static const Color baseColor = Color(0xff759896); 39 | 40 | static const Color backgroundColor = Color(0xffE0E0E0); 41 | 42 | static const Color buttonBackgroundColor = Color(0xffF2F2F2); 43 | 44 | static const Color greyColor = Color(0xffB7B7B7); 45 | 46 | static const Color baseTextColor = Color(0xff2D2D2D); 47 | 48 | static const Color paleTextColor = Color(0xff676767); 49 | 50 | static const Color redTextColor = Color(0xffE80000); 51 | 52 | static const Color greyTextColor = Color(0xff626262); 53 | } 54 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "todo") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.todo") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) isar_flutter_libs_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "IsarFlutterLibsPlugin"); 14 | isar_flutter_libs_plugin_register_with_registrar(isar_flutter_libs_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | isar_flutter_libs 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "todo"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "todo"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import isar_flutter_libs 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = todo 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.todo 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "50.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "5.2.0" 18 | analyzer_plugin: 19 | dependency: transitive 20 | description: 21 | name: analyzer_plugin 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "0.11.2" 25 | ansicolor: 26 | dependency: transitive 27 | description: 28 | name: ansicolor 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.0.1" 32 | args: 33 | dependency: transitive 34 | description: 35 | name: args 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "2.3.1" 39 | async: 40 | dependency: transitive 41 | description: 42 | name: async 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "2.9.0" 46 | boolean_selector: 47 | dependency: transitive 48 | description: 49 | name: boolean_selector 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "2.1.0" 53 | build: 54 | dependency: transitive 55 | description: 56 | name: build 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "2.3.1" 60 | build_config: 61 | dependency: transitive 62 | description: 63 | name: build_config 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.1.1" 67 | build_daemon: 68 | dependency: transitive 69 | description: 70 | name: build_daemon 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "3.1.0" 74 | build_resolvers: 75 | dependency: transitive 76 | description: 77 | name: build_resolvers 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "2.1.0" 81 | build_runner: 82 | dependency: "direct dev" 83 | description: 84 | name: build_runner 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "2.3.3" 88 | build_runner_core: 89 | dependency: transitive 90 | description: 91 | name: build_runner_core 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "7.2.7" 95 | built_collection: 96 | dependency: transitive 97 | description: 98 | name: built_collection 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "5.1.1" 102 | built_value: 103 | dependency: transitive 104 | description: 105 | name: built_value 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "8.4.3" 109 | characters: 110 | dependency: transitive 111 | description: 112 | name: characters 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "1.2.1" 116 | checked_yaml: 117 | dependency: transitive 118 | description: 119 | name: checked_yaml 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "2.0.2" 123 | clock: 124 | dependency: transitive 125 | description: 126 | name: clock 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "1.1.1" 130 | code_builder: 131 | dependency: transitive 132 | description: 133 | name: code_builder 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "4.4.0" 137 | collection: 138 | dependency: transitive 139 | description: 140 | name: collection 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "1.16.0" 144 | convert: 145 | dependency: transitive 146 | description: 147 | name: convert 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "3.1.1" 151 | crypto: 152 | dependency: transitive 153 | description: 154 | name: crypto 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "3.0.2" 158 | csslib: 159 | dependency: transitive 160 | description: 161 | name: csslib 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "0.17.2" 165 | cupertino_icons: 166 | dependency: "direct main" 167 | description: 168 | name: cupertino_icons 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "1.0.5" 172 | dart_code_metrics: 173 | dependency: "direct dev" 174 | description: 175 | name: dart_code_metrics 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "5.4.0" 179 | dart_code_metrics_presets: 180 | dependency: transitive 181 | description: 182 | name: dart_code_metrics_presets 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "1.0.1" 186 | dart_style: 187 | dependency: transitive 188 | description: 189 | name: dart_style 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "2.2.4" 193 | dartx: 194 | dependency: transitive 195 | description: 196 | name: dartx 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "1.1.0" 200 | fake_async: 201 | dependency: transitive 202 | description: 203 | name: fake_async 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "1.3.1" 207 | ffi: 208 | dependency: transitive 209 | description: 210 | name: ffi 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "2.0.1" 214 | file: 215 | dependency: transitive 216 | description: 217 | name: file 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "6.1.4" 221 | fixnum: 222 | dependency: transitive 223 | description: 224 | name: fixnum 225 | url: "https://pub.dartlang.org" 226 | source: hosted 227 | version: "1.0.1" 228 | flutter: 229 | dependency: "direct main" 230 | description: flutter 231 | source: sdk 232 | version: "0.0.0" 233 | flutter_lints: 234 | dependency: "direct dev" 235 | description: 236 | name: flutter_lints 237 | url: "https://pub.dartlang.org" 238 | source: hosted 239 | version: "2.0.1" 240 | flutter_localizations: 241 | dependency: "direct main" 242 | description: flutter 243 | source: sdk 244 | version: "0.0.0" 245 | flutter_riverpod: 246 | dependency: "direct main" 247 | description: 248 | name: flutter_riverpod 249 | url: "https://pub.dartlang.org" 250 | source: hosted 251 | version: "2.1.3" 252 | flutter_test: 253 | dependency: "direct dev" 254 | description: flutter 255 | source: sdk 256 | version: "0.0.0" 257 | flutter_web_plugins: 258 | dependency: transitive 259 | description: flutter 260 | source: sdk 261 | version: "0.0.0" 262 | freezed: 263 | dependency: "direct main" 264 | description: 265 | name: freezed 266 | url: "https://pub.dartlang.org" 267 | source: hosted 268 | version: "2.3.2" 269 | freezed_annotation: 270 | dependency: transitive 271 | description: 272 | name: freezed_annotation 273 | url: "https://pub.dartlang.org" 274 | source: hosted 275 | version: "2.2.0" 276 | frontend_server_client: 277 | dependency: transitive 278 | description: 279 | name: frontend_server_client 280 | url: "https://pub.dartlang.org" 281 | source: hosted 282 | version: "3.2.0" 283 | glob: 284 | dependency: transitive 285 | description: 286 | name: glob 287 | url: "https://pub.dartlang.org" 288 | source: hosted 289 | version: "2.1.1" 290 | go_router: 291 | dependency: "direct main" 292 | description: 293 | name: go_router 294 | url: "https://pub.dartlang.org" 295 | source: hosted 296 | version: "6.0.1" 297 | graphs: 298 | dependency: transitive 299 | description: 300 | name: graphs 301 | url: "https://pub.dartlang.org" 302 | source: hosted 303 | version: "2.2.0" 304 | html: 305 | dependency: transitive 306 | description: 307 | name: html 308 | url: "https://pub.dartlang.org" 309 | source: hosted 310 | version: "0.15.1" 311 | http: 312 | dependency: transitive 313 | description: 314 | name: http 315 | url: "https://pub.dartlang.org" 316 | source: hosted 317 | version: "0.13.5" 318 | http_multi_server: 319 | dependency: transitive 320 | description: 321 | name: http_multi_server 322 | url: "https://pub.dartlang.org" 323 | source: hosted 324 | version: "3.2.1" 325 | http_parser: 326 | dependency: transitive 327 | description: 328 | name: http_parser 329 | url: "https://pub.dartlang.org" 330 | source: hosted 331 | version: "4.0.2" 332 | intl: 333 | dependency: "direct main" 334 | description: 335 | name: intl 336 | url: "https://pub.dartlang.org" 337 | source: hosted 338 | version: "0.17.0" 339 | io: 340 | dependency: transitive 341 | description: 342 | name: io 343 | url: "https://pub.dartlang.org" 344 | source: hosted 345 | version: "1.0.3" 346 | isar: 347 | dependency: "direct main" 348 | description: 349 | name: isar 350 | url: "https://pub.dartlang.org" 351 | source: hosted 352 | version: "3.0.5" 353 | isar_flutter_libs: 354 | dependency: "direct main" 355 | description: 356 | name: isar_flutter_libs 357 | url: "https://pub.dartlang.org" 358 | source: hosted 359 | version: "3.0.5" 360 | isar_generator: 361 | dependency: "direct dev" 362 | description: 363 | name: isar_generator 364 | url: "https://pub.dartlang.org" 365 | source: hosted 366 | version: "3.0.5" 367 | js: 368 | dependency: transitive 369 | description: 370 | name: js 371 | url: "https://pub.dartlang.org" 372 | source: hosted 373 | version: "0.6.4" 374 | json_annotation: 375 | dependency: transitive 376 | description: 377 | name: json_annotation 378 | url: "https://pub.dartlang.org" 379 | source: hosted 380 | version: "4.7.0" 381 | json_serializable: 382 | dependency: "direct dev" 383 | description: 384 | name: json_serializable 385 | url: "https://pub.dartlang.org" 386 | source: hosted 387 | version: "6.5.4" 388 | lints: 389 | dependency: transitive 390 | description: 391 | name: lints 392 | url: "https://pub.dartlang.org" 393 | source: hosted 394 | version: "2.0.1" 395 | logger: 396 | dependency: "direct main" 397 | description: 398 | name: logger 399 | url: "https://pub.dartlang.org" 400 | source: hosted 401 | version: "1.1.0" 402 | logging: 403 | dependency: transitive 404 | description: 405 | name: logging 406 | url: "https://pub.dartlang.org" 407 | source: hosted 408 | version: "1.1.0" 409 | matcher: 410 | dependency: transitive 411 | description: 412 | name: matcher 413 | url: "https://pub.dartlang.org" 414 | source: hosted 415 | version: "0.12.12" 416 | material_color_utilities: 417 | dependency: transitive 418 | description: 419 | name: material_color_utilities 420 | url: "https://pub.dartlang.org" 421 | source: hosted 422 | version: "0.1.5" 423 | meta: 424 | dependency: transitive 425 | description: 426 | name: meta 427 | url: "https://pub.dartlang.org" 428 | source: hosted 429 | version: "1.8.0" 430 | mime: 431 | dependency: transitive 432 | description: 433 | name: mime 434 | url: "https://pub.dartlang.org" 435 | source: hosted 436 | version: "1.0.4" 437 | package_config: 438 | dependency: transitive 439 | description: 440 | name: package_config 441 | url: "https://pub.dartlang.org" 442 | source: hosted 443 | version: "2.1.0" 444 | path: 445 | dependency: transitive 446 | description: 447 | name: path 448 | url: "https://pub.dartlang.org" 449 | source: hosted 450 | version: "1.8.2" 451 | petitparser: 452 | dependency: transitive 453 | description: 454 | name: petitparser 455 | url: "https://pub.dartlang.org" 456 | source: hosted 457 | version: "5.1.0" 458 | platform: 459 | dependency: transitive 460 | description: 461 | name: platform 462 | url: "https://pub.dartlang.org" 463 | source: hosted 464 | version: "3.1.0" 465 | pool: 466 | dependency: transitive 467 | description: 468 | name: pool 469 | url: "https://pub.dartlang.org" 470 | source: hosted 471 | version: "1.5.1" 472 | process: 473 | dependency: transitive 474 | description: 475 | name: process 476 | url: "https://pub.dartlang.org" 477 | source: hosted 478 | version: "4.2.4" 479 | pub_semver: 480 | dependency: transitive 481 | description: 482 | name: pub_semver 483 | url: "https://pub.dartlang.org" 484 | source: hosted 485 | version: "2.1.3" 486 | pub_updater: 487 | dependency: transitive 488 | description: 489 | name: pub_updater 490 | url: "https://pub.dartlang.org" 491 | source: hosted 492 | version: "0.2.3" 493 | pubspec_parse: 494 | dependency: transitive 495 | description: 496 | name: pubspec_parse 497 | url: "https://pub.dartlang.org" 498 | source: hosted 499 | version: "1.2.1" 500 | riverpod: 501 | dependency: transitive 502 | description: 503 | name: riverpod 504 | url: "https://pub.dartlang.org" 505 | source: hosted 506 | version: "2.1.3" 507 | shelf: 508 | dependency: transitive 509 | description: 510 | name: shelf 511 | url: "https://pub.dartlang.org" 512 | source: hosted 513 | version: "1.4.0" 514 | shelf_web_socket: 515 | dependency: transitive 516 | description: 517 | name: shelf_web_socket 518 | url: "https://pub.dartlang.org" 519 | source: hosted 520 | version: "1.0.3" 521 | sky_engine: 522 | dependency: transitive 523 | description: flutter 524 | source: sdk 525 | version: "0.0.99" 526 | source_gen: 527 | dependency: transitive 528 | description: 529 | name: source_gen 530 | url: "https://pub.dartlang.org" 531 | source: hosted 532 | version: "1.2.6" 533 | source_helper: 534 | dependency: transitive 535 | description: 536 | name: source_helper 537 | url: "https://pub.dartlang.org" 538 | source: hosted 539 | version: "1.3.3" 540 | source_span: 541 | dependency: transitive 542 | description: 543 | name: source_span 544 | url: "https://pub.dartlang.org" 545 | source: hosted 546 | version: "1.9.0" 547 | stack_trace: 548 | dependency: transitive 549 | description: 550 | name: stack_trace 551 | url: "https://pub.dartlang.org" 552 | source: hosted 553 | version: "1.10.0" 554 | state_notifier: 555 | dependency: transitive 556 | description: 557 | name: state_notifier 558 | url: "https://pub.dartlang.org" 559 | source: hosted 560 | version: "0.7.2+1" 561 | stream_channel: 562 | dependency: transitive 563 | description: 564 | name: stream_channel 565 | url: "https://pub.dartlang.org" 566 | source: hosted 567 | version: "2.1.0" 568 | stream_transform: 569 | dependency: transitive 570 | description: 571 | name: stream_transform 572 | url: "https://pub.dartlang.org" 573 | source: hosted 574 | version: "2.1.0" 575 | string_scanner: 576 | dependency: transitive 577 | description: 578 | name: string_scanner 579 | url: "https://pub.dartlang.org" 580 | source: hosted 581 | version: "1.1.1" 582 | term_glyph: 583 | dependency: transitive 584 | description: 585 | name: term_glyph 586 | url: "https://pub.dartlang.org" 587 | source: hosted 588 | version: "1.2.1" 589 | test_api: 590 | dependency: transitive 591 | description: 592 | name: test_api 593 | url: "https://pub.dartlang.org" 594 | source: hosted 595 | version: "0.4.12" 596 | time: 597 | dependency: transitive 598 | description: 599 | name: time 600 | url: "https://pub.dartlang.org" 601 | source: hosted 602 | version: "2.1.3" 603 | timing: 604 | dependency: transitive 605 | description: 606 | name: timing 607 | url: "https://pub.dartlang.org" 608 | source: hosted 609 | version: "1.0.0" 610 | typed_data: 611 | dependency: transitive 612 | description: 613 | name: typed_data 614 | url: "https://pub.dartlang.org" 615 | source: hosted 616 | version: "1.3.1" 617 | vector_math: 618 | dependency: transitive 619 | description: 620 | name: vector_math 621 | url: "https://pub.dartlang.org" 622 | source: hosted 623 | version: "2.1.2" 624 | watcher: 625 | dependency: transitive 626 | description: 627 | name: watcher 628 | url: "https://pub.dartlang.org" 629 | source: hosted 630 | version: "1.0.2" 631 | web_socket_channel: 632 | dependency: transitive 633 | description: 634 | name: web_socket_channel 635 | url: "https://pub.dartlang.org" 636 | source: hosted 637 | version: "2.3.0" 638 | xml: 639 | dependency: transitive 640 | description: 641 | name: xml 642 | url: "https://pub.dartlang.org" 643 | source: hosted 644 | version: "6.1.0" 645 | xxh3: 646 | dependency: transitive 647 | description: 648 | name: xxh3 649 | url: "https://pub.dartlang.org" 650 | source: hosted 651 | version: "1.0.1" 652 | yaml: 653 | dependency: transitive 654 | description: 655 | name: yaml 656 | url: "https://pub.dartlang.org" 657 | source: hosted 658 | version: "3.1.1" 659 | sdks: 660 | dart: ">=2.18.6 <3.0.0" 661 | flutter: ">=3.3.0" 662 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: todo 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: "none" # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | # In Windows, build-name is used as the major, minor, and patch parts 19 | # of the product and file versions while build-number is used as the build suffix. 20 | version: 1.0.0+1 21 | 22 | environment: 23 | sdk: ">=2.18.6 <3.0.0" 24 | 25 | # Dependencies specify other packages that your package needs in order to work. 26 | # To automatically upgrade your package dependencies to the latest versions 27 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 28 | # dependencies can be manually updated by changing the version numbers below to 29 | # the latest version available on pub.dev. To see which dependencies have newer 30 | # versions available, run `flutter pub outdated`. 31 | dependencies: 32 | 33 | # The following adds the Cupertino Icons font to your application. 34 | # Use with the CupertinoIcons class for iOS style icons. 35 | cupertino_icons: ^1.0.2 36 | flutter: 37 | sdk: flutter 38 | flutter_localizations: 39 | sdk: flutter 40 | flutter_riverpod: ^2.1.3 41 | freezed: ^2.3.2 42 | go_router: ^6.0.1 43 | intl: ^0.17.0 44 | isar: ^3.0.5 45 | isar_flutter_libs: ^3.0.5 46 | logger: ^1.1.0 47 | 48 | dev_dependencies: 49 | build_runner: ^2.3.3 50 | dart_code_metrics: ^5.4.0 51 | 52 | # The "flutter_lints" package below contains a set of recommended lints to 53 | # encourage good coding practices. The lint set provided by the package is 54 | # activated in the `analysis_options.yaml` file located at the root of your 55 | # package. See that file for information about deactivating specific lint 56 | # rules and activating additional ones. 57 | flutter_lints: ^2.0.0 58 | flutter_test: 59 | sdk: flutter 60 | isar_generator: ^3.0.5 61 | json_serializable: ^6.5.4 62 | 63 | # For information on the generic Dart part of this file, see the 64 | # following page: https://dart.dev/tools/pub/pubspec 65 | # The following section is specific to Flutter packages. 66 | flutter: 67 | # The following line ensures that the Material Icons font is 68 | # included with your application, so that you can use the icons in 69 | # the material Icons class. 70 | uses-material-design: true 71 | # To add assets to your application, add an assets section, like this: 72 | # assets: 73 | # - images/a_dot_burr.jpeg 74 | # - images/a_dot_ham.jpeg 75 | # An image asset can refer to one or more resolution-specific "variants", see 76 | # https://flutter.dev/assets-and-images/#resolution-aware 77 | # For details regarding adding assets from package dependencies, see 78 | # https://flutter.dev/assets-and-images/#from-packages 79 | # To add custom fonts to your application, add a fonts section here, 80 | # in this "flutter" section. Each entry in this list should have a 81 | # "family" key with the font family name, and a "fonts" key with a 82 | # list giving the asset and other descriptors for the font. For 83 | # example: 84 | # fonts: 85 | # - family: Schyler 86 | # fonts: 87 | # - asset: fonts/Schyler-Regular.ttf 88 | # - asset: fonts/Schyler-Italic.ttf 89 | # style: italic 90 | # - family: Trajan Pro 91 | # fonts: 92 | # - asset: fonts/TrajanPro.ttf 93 | # - asset: fonts/TrajanPro_Bold.ttf 94 | # weight: 700 95 | # 96 | # For details regarding fonts from package dependencies, 97 | # see https://flutter.dev/custom-fonts/#from-packages 98 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:todo/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /todo_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/todo_demo.gif -------------------------------------------------------------------------------- /todo_demo.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/todo_demo.mov -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | todo 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "todo", 3 | "short_name": "todo", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(todo LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "todo") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | IsarFlutterLibsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | isar_flutter_libs 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "todo" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "todo" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "todo.exe" "\0" 98 | VALUE "ProductName", "todo" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"todo", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomamoi/todo_app/d3c9aeb81919b80360f4b45814bf98eda29774d9/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | --------------------------------------------------------------------------------