├── .github └── FUNDING.yml ├── .gitignore ├── .metadata ├── .run ├── main_dart.xml └── main_emulator_dart.xml ├── .vscode └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── build.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ ├── google-services.json │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── 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 │ │ │ │ └── xml │ │ │ │ └── network_security_config.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── build.yaml ├── firebase.json ├── firebase │ ├── .firebaserc │ ├── .gitignore │ ├── database.rules.json │ ├── firebase.json │ ├── firestore.indexes.json │ ├── firestore.rules │ ├── functions │ │ ├── .gitignore │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ └── tslint.json │ ├── public │ │ └── index.html │ └── storage.rules ├── 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 │ │ ├── GoogleService-Info.plist │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ ├── app.dart │ ├── firebase_options.dart │ ├── main.dart │ ├── model │ │ ├── firestore │ │ │ ├── firestore.dart │ │ │ └── user │ │ │ │ ├── user.dart │ │ │ │ ├── user.freezed.dart │ │ │ │ └── user.g.dart │ │ └── service │ │ │ ├── authenticator.dart │ │ │ ├── count_incrementer.dart │ │ │ ├── service.dart │ │ │ ├── user_docs_provider.dart │ │ │ └── users_deleter.dart │ ├── pages │ │ ├── home_page.dart │ │ ├── paging_page │ │ │ ├── paging_data.dart │ │ │ ├── paging_data.freezed.dart │ │ │ ├── paging_data.g.dart │ │ │ ├── paging_page.dart │ │ │ └── paging_page_controller.dart │ │ └── user_counter_page.dart │ ├── router.dart │ └── util │ │ ├── logger.dart │ │ └── util.dart ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Podfile.lock │ ├── 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 │ │ ├── GoogleService-Info.plist │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── lib ├── firestore_ref.dart └── src │ ├── collection_paging_controller.dart │ ├── collection_ref.dart │ ├── document.dart │ ├── document_list.dart │ ├── document_ref.dart │ ├── firestore_operation_counter.dart │ ├── functions.dart │ ├── timestamp.dart │ └── utils.dart ├── pubspec.lock ├── pubspec.yaml └── test └── firestore_ref_test.dart /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: 2 | - mono0926 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | .vscode/settings.json 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 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Exceptions to above rules. 45 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 46 | 47 | vendor/ 48 | 49 | **/fastlane/report.xml 50 | .fvm/flutter_sdk -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 365f577c707b092f9b97b62b0cdb331c2d7fcf75 8 | channel: dev 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /.run/main_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.run/main_emulator_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Debug", 9 | "request": "launch", 10 | "type": "dart", 11 | "cwd": "example" 12 | }, 13 | { 14 | "name": "Release", 15 | "request": "launch", 16 | "type": "dart", 17 | "cwd": "example", 18 | "flutterMode": "release" 19 | }, 20 | { 21 | "name": "Emulator", 22 | "request": "launch", 23 | "type": "dart", 24 | "cwd": "example", 25 | "args": ["--dart-define=IS_EMULATOR=true"] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.15.0 2 | 3 | - Upgrade to Flutter 3.32/Dart 3.8 4 | 5 | ## 0.14.2 6 | 7 | - Upgrade cloud_firestore 8 | 9 | ## 0.14.1 10 | 11 | - Upgrade cloud_firestore 12 | 13 | ## 0.14.0 14 | 15 | - Delete JsonConveters 16 | - Use [json_converter_helper](https://pub.dev/packages/json_converter_helper) instead. 17 | 18 | ## 0.13.3 19 | 20 | - Fix CollectionPagingController hasMore flicking 21 | 22 | ## 0.13.2 23 | 24 | - Fix the error when CollectionPagingController is closed 25 | 26 | ## 0.13.1 27 | 28 | - Enhance paging 29 | 30 | ## 0.13.0 31 | 32 | - Upgrade cloud_firestore dependency to ">=3.0.0 <4.0.0" from ">=2.0.0 <3.0.0" 33 | 34 | ## 0.12.4+1 35 | 36 | - Refactor ==/hashCode of DocumentRef 37 | 38 | ## 0.12.4 39 | 40 | - Enhance hasMore of CollectionPagingController 41 | 42 | ## 0.12.3 43 | 44 | - Fix hasMore of CollectionPagingController 45 | 46 | ## 0.12.2 47 | 48 | - Change to `Future` from `Future` of DocumentRef.get return value 49 | - Refactor example 50 | 51 | ## 0.12.1 52 | 53 | - Delete useFirestoreEmulator in favor of FirebaseFirestore.instance.useFirestoreEmulator 54 | 55 | ## 0.12.0 56 | 57 | - Depend on Dart 2.13.0 to use non-function type aliases for JsonMap 58 | 59 | ## 0.11.3 60 | 61 | - Change second type parameter of PassthroughConverter to `Object?` from `T` to suppress redundant cast and bug 62 | 63 | ## 0.11.2 64 | 65 | - Update to firebase_core >=1.1.1 <2.0.0 and refactor hashCode of DocumentRef 66 | 67 | ## 0.11.1 68 | 69 | - Update to rxdart 0.27.0 70 | 71 | ## 0.11.0 72 | 73 | - Upgrade cloud_firestore to ">=2.0.0 <3.0.0" 74 | 75 | ## 0.10.0 76 | 77 | - Migrate to null safety 78 | 79 | ## 0.9.2 80 | 81 | - Add ISO8601Converter 82 | 83 | ## 0.9.1 84 | 85 | - Support `GetOptions` 86 | 87 | ## 0.9.0 88 | 89 | - Upgrade cloud_firestore to ^0.14.0 90 | - There are some breaking changes to change DocumentRef to more strong typed 91 | 92 | ## 0.8.21 93 | 94 | - Add `FirestoreOperationCounter` 95 | - If `recordFirestoreOperationCount`(default: false) is true, all operations is logged on memory and trace them. 96 | 97 | ## 0.8.20 98 | 99 | - Add emptyCollectionIfNull to DocumentReferenceSetConverter/DocumentReferenceListConverter 100 | 101 | ## 0.8.19 102 | 103 | - Make DocumentReferenceSetConverter to const 104 | 105 | ## 0.8.18 106 | 107 | - Add == and hashCode to DocumentRef and CollectionRef 108 | 109 | ## 0.8.17 110 | 111 | - Omit `createdAt` of `replacingTimestamp` 112 | 113 | ## 0.8.16 114 | 115 | - Fix DocumentReferenceListConverter 116 | 117 | ## 0.8.15 118 | 119 | - Add ColorConverter 120 | 121 | ## 0.8.14 122 | 123 | - Rename to documentListResult and make it public 124 | 125 | ## 0.8.13 126 | 127 | - Add map version of `documents`, which is updated efficiently same as list 128 | 129 | ## 0.8.12 130 | 131 | - Support paging 132 | 133 | ## 0.8.11 134 | 135 | - Fix a bug when `documents` is called multiple times 136 | 137 | ## 0.8.10 138 | 139 | - Add `useFirestoreEmulator` function 140 | 141 | ## 0.8.9 142 | 143 | - Fix `Document`'s `id` error when `ref` is null 144 | 145 | ## 0.8.8 146 | 147 | - Add `deleteDocuments` function 148 | 149 | ## 0.8.7 150 | 151 | - Some cleanup 152 | 153 | ## 0.8.3 154 | 155 | - Change deleteAllDocuments return type to Future> 156 | 157 | ## 0.8.2 158 | 159 | - Change deleteAllDocuments return type to Future>, which is deleted document ids 160 | 161 | ## 0.8.1 162 | 163 | - Add deleteAllDocuments to CollectionRef 164 | 165 | ## 0.8.0 166 | 167 | - Use freezed at example 168 | - Refactor encoder/decoder 169 | - Support transaction 170 | - Change Document id(String) to ref(DocumentReference) 171 | 172 | ## 0.7.0 173 | 174 | - Delete helper methods in favor of cloud_firestore_web 175 | 176 | ## 0.6.0 177 | 178 | - Split out HasTimestamp from Entity 179 | - Change Entity to mixin from abstract class 180 | - See: https://github.com/mono0926/flutter_firestore_ref/commit/45ff00de4ce6ec7502eaa4248b2dbf5084e09837 181 | 182 | ## 0.5.1 183 | 184 | - Fix updateData 185 | - https://github.com/mono0926/flutter_firestore_ref/pull/2 186 | - Thanks to @takuyaohashi(https://github.com/takuyaohashi) 187 | 188 | ## 0.5.0 189 | 190 | - Update dependencies 191 | 192 | ## 0.4.1 193 | 194 | - Fix documentID bug 195 | 196 | ## 0.4.0 197 | 198 | - Dart version: >=2.6.0-dev 199 | - Use extension 200 | 201 | ## 0.3.0 202 | 203 | - Update to firebase 6.0.0 204 | - Support collection group query for web 205 | 206 | ## 0.2.2 207 | 208 | - Set `configureFirestore`'s `persistenceEnabled` default value to `true`. 209 | 210 | ## 0.2.1 211 | 212 | - Rename to data from json 213 | 214 | ## 0.2.0 215 | 216 | - Support for web. 217 | 218 | ## 0.1.0 219 | 220 | - Several enhancements. 221 | 222 | ## 0.0.3 223 | 224 | - Support batch write. 225 | 226 | ## 0.0.2 227 | 228 | - Add parseJson. 229 | 230 | ## 0.0.1 231 | 232 | - Initial release. 233 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Masayuki Ono 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # firestore_ref 2 | 3 | Cross-platform(including web) Firestore type-safe wrapper. 4 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://pub.dev/packages/pedantic_mono 2 | include: package:pedantic_mono/analysis_options.yaml 3 | analyzer: 4 | exclude: 5 | - lib/generated_plugin_registrant.dart 6 | - lib/firebase_options.dart 7 | - example/lib/firebase_options.dart 8 | errors: 9 | # https://github.com/rrousselGit/freezed/issues/488 10 | invalid_annotation_target: ignore 11 | linter: 12 | rules: 13 | specify_nonobvious_property_types: false 14 | -------------------------------------------------------------------------------- /build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | builders: 4 | json_serializable: 5 | options: 6 | any_map: true 7 | explicit_to_json: true 8 | source_gen|combining_builder: 9 | options: 10 | ignore_for_file: 11 | - type=lint 12 | - implicit_dynamic_parameter 13 | - implicit_dynamic_type 14 | - implicit_dynamic_method 15 | - strict_raw_type 16 | - unused_field 17 | - unused_element 18 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Exceptions to above rules. 40 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 41 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "5dcb86f68f239346676ceb1ed1ea385bd215fba1" 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: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 17 | base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 18 | - platform: web 19 | create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 20 | base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter application. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | ../analysis_options.yaml -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | // START: FlutterFire Configuration 4 | id 'com.google.gms.google-services' 5 | // END: FlutterFire Configuration 6 | id "kotlin-android" 7 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 8 | id "dev.flutter.flutter-gradle-plugin" 9 | } 10 | 11 | def localProperties = new Properties() 12 | def localPropertiesFile = rootProject.file("local.properties") 13 | if (localPropertiesFile.exists()) { 14 | localPropertiesFile.withReader("UTF-8") { reader -> 15 | localProperties.load(reader) 16 | } 17 | } 18 | 19 | def flutterVersionCode = localProperties.getProperty("flutter.versionCode") 20 | if (flutterVersionCode == null) { 21 | flutterVersionCode = "1" 22 | } 23 | 24 | def flutterVersionName = localProperties.getProperty("flutter.versionName") 25 | if (flutterVersionName == null) { 26 | flutterVersionName = "1.0" 27 | } 28 | 29 | android { 30 | namespace = "com.example.example" 31 | compileSdk = flutter.compileSdkVersion 32 | ndkVersion = flutter.ndkVersion 33 | 34 | compileOptions { 35 | sourceCompatibility = JavaVersion.VERSION_1_8 36 | targetCompatibility = JavaVersion.VERSION_1_8 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId = "com.example.example" 42 | // You can update the following values to match your application needs. 43 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 44 | minSdk = flutter.minSdkVersion 45 | targetSdk = flutter.targetSdkVersion 46 | versionCode = flutterVersionCode.toInteger() 47 | versionName = flutterVersionName 48 | } 49 | 50 | buildTypes { 51 | release { 52 | // TODO: Add your own signing config for the release build. 53 | // Signing with the debug keys for now, so `flutter run --release` works. 54 | signingConfig = signingConfigs.debug 55 | } 56 | } 57 | } 58 | 59 | flutter { 60 | source = "../.." 61 | } 62 | -------------------------------------------------------------------------------- /example/android/app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "411503049546", 4 | "firebase_url": "https://fir-fir-mono.firebaseio.com", 5 | "project_id": "fir-fir-mono", 6 | "storage_bucket": "fir-fir-mono.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:411503049546:android:e2bbb912085fa60a38dfb3", 12 | "android_client_info": { 13 | "package_name": "com.example.app" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 19 | "client_type": 3 20 | } 21 | ], 22 | "api_key": [ 23 | { 24 | "current_key": "AIzaSyC68jwLKzJ8E61j40yCwRQeGeVIm4nO0kk" 25 | } 26 | ], 27 | "services": { 28 | "appinvite_service": { 29 | "other_platform_oauth_client": [ 30 | { 31 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 32 | "client_type": 3 33 | }, 34 | { 35 | "client_id": "411503049546-4gfgu18j1b16t2i11682ida12n90lm3t.apps.googleusercontent.com", 36 | "client_type": 2, 37 | "ios_info": { 38 | "bundle_id": "com.mono0926.example" 39 | } 40 | } 41 | ] 42 | } 43 | } 44 | }, 45 | { 46 | "client_info": { 47 | "mobilesdk_app_id": "1:411503049546:android:1d02260d28cada9c38dfb3", 48 | "android_client_info": { 49 | "package_name": "com.example.example" 50 | } 51 | }, 52 | "oauth_client": [ 53 | { 54 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 55 | "client_type": 3 56 | } 57 | ], 58 | "api_key": [ 59 | { 60 | "current_key": "AIzaSyC68jwLKzJ8E61j40yCwRQeGeVIm4nO0kk" 61 | } 62 | ], 63 | "services": { 64 | "appinvite_service": { 65 | "other_platform_oauth_client": [ 66 | { 67 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 68 | "client_type": 3 69 | }, 70 | { 71 | "client_id": "411503049546-4gfgu18j1b16t2i11682ida12n90lm3t.apps.googleusercontent.com", 72 | "client_type": 2, 73 | "ios_info": { 74 | "bundle_id": "com.mono0926.example" 75 | } 76 | } 77 | ] 78 | } 79 | } 80 | }, 81 | { 82 | "client_info": { 83 | "mobilesdk_app_id": "1:411503049546:android:0781670387fc62b838dfb3", 84 | "android_client_info": { 85 | "package_name": "com.example.flutter_playground" 86 | } 87 | }, 88 | "oauth_client": [ 89 | { 90 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 91 | "client_type": 3 92 | } 93 | ], 94 | "api_key": [ 95 | { 96 | "current_key": "AIzaSyC68jwLKzJ8E61j40yCwRQeGeVIm4nO0kk" 97 | } 98 | ], 99 | "services": { 100 | "appinvite_service": { 101 | "other_platform_oauth_client": [ 102 | { 103 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 104 | "client_type": 3 105 | }, 106 | { 107 | "client_id": "411503049546-4gfgu18j1b16t2i11682ida12n90lm3t.apps.googleusercontent.com", 108 | "client_type": 2, 109 | "ios_info": { 110 | "bundle_id": "com.mono0926.example" 111 | } 112 | } 113 | ] 114 | } 115 | } 116 | }, 117 | { 118 | "client_info": { 119 | "mobilesdk_app_id": "1:411503049546:android:c089168ee80717bf38dfb3", 120 | "android_client_info": { 121 | "package_name": "com.mono0926.example" 122 | } 123 | }, 124 | "oauth_client": [ 125 | { 126 | "client_id": "411503049546-fdeqtjv1jl7cjkkvn8sgi02limetqjh5.apps.googleusercontent.com", 127 | "client_type": 1, 128 | "android_info": { 129 | "package_name": "com.mono0926.example", 130 | "certificate_hash": "62ae5cab06525c1229d60752b17a866596f4da4f" 131 | } 132 | }, 133 | { 134 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 135 | "client_type": 3 136 | } 137 | ], 138 | "api_key": [ 139 | { 140 | "current_key": "AIzaSyC68jwLKzJ8E61j40yCwRQeGeVIm4nO0kk" 141 | } 142 | ], 143 | "services": { 144 | "appinvite_service": { 145 | "other_platform_oauth_client": [ 146 | { 147 | "client_id": "411503049546-hh9ncrvidn4pvi07leu61mdvoqib0fkl.apps.googleusercontent.com", 148 | "client_type": 3 149 | }, 150 | { 151 | "client_id": "411503049546-4gfgu18j1b16t2i11682ida12n90lm3t.apps.googleusercontent.com", 152 | "client_type": 2, 153 | "ios_info": { 154 | "bundle_id": "com.mono0926.example" 155 | } 156 | } 157 | ] 158 | } 159 | } 160 | } 161 | ], 162 | "configuration_version": "1" 163 | } -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10.0.2.2 5 | 6 | 7 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = "../build" 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(":app") 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/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.6.3-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "7.3.0" apply false 22 | // START: FlutterFire Configuration 23 | id "com.google.gms.google-services" version "4.3.15" apply false 24 | // END: FlutterFire Configuration 25 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false 26 | } 27 | 28 | include ":app" 29 | -------------------------------------------------------------------------------- /example/build.yaml: -------------------------------------------------------------------------------- 1 | ../build.yaml -------------------------------------------------------------------------------- /example/firebase.json: -------------------------------------------------------------------------------- 1 | {"flutter":{"platforms":{"android":{"default":{"projectId":"fir-fir-mono","appId":"1:411503049546:android:1d02260d28cada9c38dfb3","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"fir-fir-mono","appId":"1:411503049546:ios:2fd66156364836ac38dfb3","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"fir-fir-mono","appId":"1:411503049546:ios:2fd66156364836ac38dfb3","uploadDebugSymbols":false,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"fir-fir-mono","configurations":{"android":"1:411503049546:android:1d02260d28cada9c38dfb3","ios":"1:411503049546:ios:2fd66156364836ac38dfb3","macos":"1:411503049546:ios:2fd66156364836ac38dfb3","web":"1:411503049546:web:3f41ceee03b1020038dfb3","windows":"1:411503049546:web:3f41ceee03b1020038dfb3"}}}}}} -------------------------------------------------------------------------------- /example/firebase/.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "fir-fir-mono" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /example/firebase/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | firebase-debug.log* 8 | 9 | # Firebase cache 10 | .firebase/ 11 | 12 | # Firebase config 13 | 14 | # Uncomment this if you'd like others to create their own Firebase project. 15 | # For a team working on the same Firebase project(s), it is recommended to leave 16 | # it commented so all members can deploy to the same project(s) in .firebaserc. 17 | # .firebaserc 18 | 19 | # Runtime data 20 | pids 21 | *.pid 22 | *.seed 23 | *.pid.lock 24 | 25 | # Directory for instrumented libs generated by jscoverage/JSCover 26 | lib-cov 27 | 28 | # Coverage directory used by tools like istanbul 29 | coverage 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (http://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | 49 | # Optional npm cache directory 50 | .npm 51 | 52 | # Optional eslint cache 53 | .eslintcache 54 | 55 | # Optional REPL history 56 | .node_repl_history 57 | 58 | # Output of 'npm pack' 59 | *.tgz 60 | 61 | # Yarn Integrity file 62 | .yarn-integrity 63 | 64 | # dotenv environment variables file 65 | .env 66 | -------------------------------------------------------------------------------- /example/firebase/database.rules.json: -------------------------------------------------------------------------------- 1 | { 2 | /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */ 3 | "rules": { 4 | ".read": false, 5 | ".write": false 6 | } 7 | } -------------------------------------------------------------------------------- /example/firebase/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "database": { 3 | "rules": "database.rules.json" 4 | }, 5 | "firestore": { 6 | "rules": "firestore.rules", 7 | "indexes": "firestore.indexes.json" 8 | }, 9 | "functions": { 10 | "predeploy": [ 11 | "npm --prefix \"$RESOURCE_DIR\" run lint", 12 | "npm --prefix \"$RESOURCE_DIR\" run build" 13 | ] 14 | }, 15 | "hosting": { 16 | "public": "public", 17 | "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], 18 | "rewrites": [ 19 | { 20 | "source": "**", 21 | "destination": "/index.html" 22 | } 23 | ] 24 | }, 25 | "storage": { 26 | "rules": "storage.rules" 27 | }, 28 | "emulators": { 29 | "auth": { 30 | "port": 9099 31 | }, 32 | "functions": { 33 | "port": 5001 34 | }, 35 | "firestore": { 36 | "port": 8080 37 | }, 38 | "database": { 39 | "port": 9000 40 | }, 41 | "hosting": { 42 | "port": 5002 43 | }, 44 | "pubsub": { 45 | "port": 8085 46 | }, 47 | "storage": { 48 | "port": 9199 49 | }, 50 | "ui": { 51 | "enabled": true 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /example/firebase/firestore.indexes.json: -------------------------------------------------------------------------------- 1 | { 2 | "indexes": [], 3 | "fieldOverrides": [ 4 | { 5 | "collectionGroup": "users", 6 | "fieldPath": "updatedAt", 7 | "indexes": [ 8 | { 9 | "order": "ASCENDING", 10 | "queryScope": "COLLECTION" 11 | }, 12 | { 13 | "order": "DESCENDING", 14 | "queryScope": "COLLECTION" 15 | }, 16 | { 17 | "arrayConfig": "CONTAINS", 18 | "queryScope": "COLLECTION" 19 | }, 20 | { 21 | "order": "DESCENDING", 22 | "queryScope": "COLLECTION_GROUP" 23 | } 24 | ] 25 | }, 26 | { 27 | "collectionGroup": "pagings", 28 | "fieldPath": "createdAt", 29 | "indexes": [ 30 | { 31 | "order": "ASCENDING", 32 | "queryScope": "COLLECTION" 33 | }, 34 | { 35 | "order": "DESCENDING", 36 | "queryScope": "COLLECTION" 37 | }, 38 | { 39 | "arrayConfig": "CONTAINS", 40 | "queryScope": "COLLECTION" 41 | }, 42 | { 43 | "order": "ASCENDING", 44 | "queryScope": "COLLECTION_GROUP" 45 | } 46 | ] 47 | } 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /example/firebase/firestore.rules: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service cloud.firestore { 3 | match /databases/{database}/documents { 4 | match /{document=**} { 5 | allow read, write: if request.auth != null; 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/firebase/functions/.gitignore: -------------------------------------------------------------------------------- 1 | ## Compiled JavaScript files 2 | **/*.js 3 | **/*.js.map 4 | 5 | # Typescript v1 declaration files 6 | typings/ 7 | 8 | node_modules/ -------------------------------------------------------------------------------- /example/firebase/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "scripts": { 4 | "lint": "tslint --project tsconfig.json", 5 | "build": "tsc", 6 | "serve": "npm run build && firebase emulators:start --only functions", 7 | "shell": "npm run build && firebase functions:shell", 8 | "start": "npm run shell", 9 | "deploy": "firebase deploy --only functions", 10 | "logs": "firebase functions:log" 11 | }, 12 | "engines": { 13 | "node": "18" 14 | }, 15 | "main": "lib/index.js", 16 | "dependencies": { 17 | "firebase-admin": "^11.4.1", 18 | "firebase-functions": "^3.24.1" 19 | }, 20 | "devDependencies": { 21 | "firebase-functions-test": "^0.3.3", 22 | "tslint": "^5.20.1", 23 | "typescript": "^4.6.4" 24 | }, 25 | "private": true 26 | } 27 | -------------------------------------------------------------------------------- /example/firebase/functions/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as functions from 'firebase-functions' 2 | 3 | export const now = functions.https.onCall((data, context) => { 4 | return { time: new Date().toISOString() } 5 | }) 6 | 7 | // // Start writing Firebase Functions 8 | // // https://firebase.google.com/docs/functions/typescript 9 | // 10 | // export const helloWorld = functions.https.onRequest((request, response) => { 11 | // response.send("Hello from Firebase!"); 12 | // }); 13 | -------------------------------------------------------------------------------- /example/firebase/functions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "noImplicitReturns": true, 5 | "noUnusedLocals": true, 6 | "outDir": "lib", 7 | "sourceMap": true, 8 | "strict": true, 9 | "target": "es2017", 10 | "skipLibCheck": true 11 | }, 12 | "compileOnSave": true, 13 | "include": ["src"] 14 | } 15 | -------------------------------------------------------------------------------- /example/firebase/functions/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | // -- Strict errors -- 4 | // These lint rules are likely always a good idea. 5 | 6 | // Force function overloads to be declared together. This ensures readers understand APIs. 7 | "adjacent-overload-signatures": true, 8 | 9 | // Do not allow the subtle/obscure comma operator. 10 | "ban-comma-operator": true, 11 | 12 | // Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules. 13 | "no-namespace": true, 14 | 15 | // Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars. 16 | "no-parameter-reassignment": true, 17 | 18 | // Force the use of ES6-style imports instead of /// imports. 19 | "no-reference": true, 20 | 21 | // Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the 22 | // code currently being edited (they may be incorrectly handling a different type case that does not exist). 23 | "no-unnecessary-type-assertion": true, 24 | 25 | // Disallow nonsensical label usage. 26 | "label-position": true, 27 | 28 | // Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }. 29 | "no-conditional-assignment": true, 30 | 31 | // Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed). 32 | "no-construct": true, 33 | 34 | // Do not allow super() to be called twice in a constructor. 35 | "no-duplicate-super": true, 36 | 37 | // Do not allow the same case to appear more than once in a switch block. 38 | "no-duplicate-switch-case": true, 39 | 40 | // Do not allow a variable to be declared more than once in the same block. Consider function parameters in this 41 | // rule. 42 | "no-duplicate-variable": [true, "check-parameters"], 43 | 44 | // Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should 45 | // instead use a separate variable name. 46 | "no-shadowed-variable": true, 47 | 48 | // Empty blocks are almost never needed. Allow the one general exception: empty catch blocks. 49 | "no-empty": [true, "allow-empty-catch"], 50 | 51 | // Functions must either be handled directly (e.g. with a catch() handler) or returned to another function. 52 | // This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on. 53 | "no-floating-promises": true, 54 | 55 | // Do not allow any imports for modules that are not in package.json. These will almost certainly fail when 56 | // deployed. 57 | "no-implicit-dependencies": true, 58 | 59 | // The 'this' keyword can only be used inside of classes. 60 | "no-invalid-this": true, 61 | 62 | // Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead. 63 | "no-string-throw": true, 64 | 65 | // Disallow control flow statements, such as return, continue, break, and throw in finally blocks. 66 | "no-unsafe-finally": true, 67 | 68 | // Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid(); 69 | "no-void-expression": [true, "ignore-arrow-function-shorthand"], 70 | 71 | // Disallow duplicate imports in the same file. 72 | "no-duplicate-imports": true, 73 | 74 | 75 | // -- Strong Warnings -- 76 | // These rules should almost never be needed, but may be included due to legacy code. 77 | // They are left as a warning to avoid frustration with blocked deploys when the developer 78 | // understand the warning and wants to deploy anyway. 79 | 80 | // Warn when an empty interface is defined. These are generally not useful. 81 | "no-empty-interface": {"severity": "warning"}, 82 | 83 | // Warn when an import will have side effects. 84 | "no-import-side-effect": {"severity": "warning"}, 85 | 86 | // Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for 87 | // most values and let for values that will change. 88 | "no-var-keyword": {"severity": "warning"}, 89 | 90 | // Prefer === and !== over == and !=. The latter operators support overloads that are often accidental. 91 | "triple-equals": {"severity": "warning"}, 92 | 93 | // Warn when using deprecated APIs. 94 | "deprecation": {"severity": "warning"}, 95 | 96 | // -- Light Warnings -- 97 | // These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info" 98 | // if TSLint supported such a level. 99 | 100 | // prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array. 101 | // (Even better: check out utils like .map if transforming an array!) 102 | "prefer-for-of": {"severity": "warning"}, 103 | 104 | // Warns if function overloads could be unified into a single function with optional or rest parameters. 105 | "unified-signatures": {"severity": "warning"}, 106 | 107 | // Prefer const for values that will not change. This better documents code. 108 | "prefer-const": {"severity": "warning"}, 109 | 110 | // Multi-line object literals and function calls should have a trailing comma. This helps avoid merge conflicts. 111 | "trailing-comma": {"severity": "warning"} 112 | }, 113 | 114 | "defaultSeverity": "error" 115 | } 116 | -------------------------------------------------------------------------------- /example/firebase/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to Firebase Hosting 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 32 | 33 | 34 |
35 |

Welcome

36 |

Firebase Hosting Setup Complete

37 |

You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!

38 | Open Hosting Documentation 39 |
40 |

Firebase SDK Loading…

41 | 42 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /example/firebase/storage.rules: -------------------------------------------------------------------------------- 1 | service firebase.storage { 2 | match /b/{bucket}/o { 3 | match /{allPaths=**} { 4 | allow read, write: if request.auth!=null; 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '10.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 | # Follow this: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/cloud_firestore/cloud_firestore/ios/cloud_firestore.podspec#L6 35 | pod 'FirebaseFirestore/WithLeveldb', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.0.0' 36 | 37 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - cloud_firestore (3.1.10): 3 | - Firebase/Firestore (= 8.11.0) 4 | - firebase_core 5 | - Flutter 6 | - cloud_functions (3.2.10): 7 | - Firebase/Functions (= 8.11.0) 8 | - firebase_core 9 | - Flutter 10 | - Firebase/Auth (8.11.0): 11 | - Firebase/CoreOnly 12 | - FirebaseAuth (~> 8.11.0) 13 | - Firebase/CoreOnly (8.11.0): 14 | - FirebaseCore (= 8.11.0) 15 | - Firebase/Firestore (8.11.0): 16 | - Firebase/CoreOnly 17 | - FirebaseFirestore (~> 8.11.0) 18 | - Firebase/Functions (8.11.0): 19 | - Firebase/CoreOnly 20 | - FirebaseFunctions (~> 8.11.0) 21 | - Firebase/Storage (8.11.0): 22 | - Firebase/CoreOnly 23 | - FirebaseStorage (~> 8.11.0) 24 | - firebase_auth (3.3.11): 25 | - Firebase/Auth (= 8.11.0) 26 | - firebase_core 27 | - Flutter 28 | - firebase_core (1.13.1): 29 | - Firebase/CoreOnly (= 8.11.0) 30 | - Flutter 31 | - firebase_storage (10.2.9): 32 | - Firebase/Storage (= 8.11.0) 33 | - firebase_core 34 | - Flutter 35 | - FirebaseAuth (8.11.0): 36 | - FirebaseCore (~> 8.0) 37 | - GoogleUtilities/AppDelegateSwizzler (~> 7.7) 38 | - GoogleUtilities/Environment (~> 7.7) 39 | - GTMSessionFetcher/Core (~> 1.5) 40 | - FirebaseCore (8.11.0): 41 | - FirebaseCoreDiagnostics (~> 8.0) 42 | - GoogleUtilities/Environment (~> 7.7) 43 | - GoogleUtilities/Logger (~> 7.7) 44 | - FirebaseCoreDiagnostics (8.14.0): 45 | - GoogleDataTransport (~> 9.1) 46 | - GoogleUtilities/Environment (~> 7.7) 47 | - GoogleUtilities/Logger (~> 7.7) 48 | - nanopb (~> 2.30908.0) 49 | - FirebaseFirestore (8.11.0): 50 | - FirebaseFirestore/AutodetectLeveldb (= 8.11.0) 51 | - FirebaseFirestore/AutodetectLeveldb (8.11.0): 52 | - FirebaseFirestore/Base 53 | - FirebaseFirestore/WithLeveldb 54 | - FirebaseFirestore/Base (8.11.0) 55 | - FirebaseFirestore/WithLeveldb (8.11.0): 56 | - FirebaseFirestore/Base 57 | - FirebaseFunctions (8.11.0): 58 | - FirebaseCore (~> 8.0) 59 | - GTMSessionFetcher/Core (~> 1.5) 60 | - FirebaseStorage (8.11.0): 61 | - FirebaseCore (~> 8.0) 62 | - GTMSessionFetcher/Core (~> 1.5) 63 | - Flutter (1.0.0) 64 | - GoogleDataTransport (9.1.2): 65 | - GoogleUtilities/Environment (~> 7.2) 66 | - nanopb (~> 2.30908.0) 67 | - PromisesObjC (< 3.0, >= 1.2) 68 | - GoogleUtilities/AppDelegateSwizzler (7.7.0): 69 | - GoogleUtilities/Environment 70 | - GoogleUtilities/Logger 71 | - GoogleUtilities/Network 72 | - GoogleUtilities/Environment (7.7.0): 73 | - PromisesObjC (< 3.0, >= 1.2) 74 | - GoogleUtilities/Logger (7.7.0): 75 | - GoogleUtilities/Environment 76 | - GoogleUtilities/Network (7.7.0): 77 | - GoogleUtilities/Logger 78 | - "GoogleUtilities/NSData+zlib" 79 | - GoogleUtilities/Reachability 80 | - "GoogleUtilities/NSData+zlib (7.7.0)" 81 | - GoogleUtilities/Reachability (7.7.0): 82 | - GoogleUtilities/Logger 83 | - GTMSessionFetcher/Core (1.7.1) 84 | - image_picker (0.0.1): 85 | - Flutter 86 | - mono_kit (0.0.1): 87 | - Flutter 88 | - nanopb (2.30908.0): 89 | - nanopb/decode (= 2.30908.0) 90 | - nanopb/encode (= 2.30908.0) 91 | - nanopb/decode (2.30908.0) 92 | - nanopb/encode (2.30908.0) 93 | - PromisesObjC (2.0.0) 94 | - url_launcher_ios (0.0.1): 95 | - Flutter 96 | 97 | DEPENDENCIES: 98 | - cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) 99 | - cloud_functions (from `.symlinks/plugins/cloud_functions/ios`) 100 | - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) 101 | - firebase_core (from `.symlinks/plugins/firebase_core/ios`) 102 | - firebase_storage (from `.symlinks/plugins/firebase_storage/ios`) 103 | - FirebaseFirestore (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `8.11.0`) 104 | - Flutter (from `Flutter`) 105 | - image_picker (from `.symlinks/plugins/image_picker/ios`) 106 | - mono_kit (from `.symlinks/plugins/mono_kit/ios`) 107 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 108 | 109 | SPEC REPOS: 110 | trunk: 111 | - Firebase 112 | - FirebaseAuth 113 | - FirebaseCore 114 | - FirebaseCoreDiagnostics 115 | - FirebaseFunctions 116 | - FirebaseStorage 117 | - GoogleDataTransport 118 | - GoogleUtilities 119 | - GTMSessionFetcher 120 | - nanopb 121 | - PromisesObjC 122 | 123 | EXTERNAL SOURCES: 124 | cloud_firestore: 125 | :path: ".symlinks/plugins/cloud_firestore/ios" 126 | cloud_functions: 127 | :path: ".symlinks/plugins/cloud_functions/ios" 128 | firebase_auth: 129 | :path: ".symlinks/plugins/firebase_auth/ios" 130 | firebase_core: 131 | :path: ".symlinks/plugins/firebase_core/ios" 132 | firebase_storage: 133 | :path: ".symlinks/plugins/firebase_storage/ios" 134 | FirebaseFirestore: 135 | :git: https://github.com/invertase/firestore-ios-sdk-frameworks.git 136 | :tag: 8.11.0 137 | Flutter: 138 | :path: Flutter 139 | image_picker: 140 | :path: ".symlinks/plugins/image_picker/ios" 141 | mono_kit: 142 | :path: ".symlinks/plugins/mono_kit/ios" 143 | url_launcher_ios: 144 | :path: ".symlinks/plugins/url_launcher_ios/ios" 145 | 146 | CHECKOUT OPTIONS: 147 | FirebaseFirestore: 148 | :git: https://github.com/invertase/firestore-ios-sdk-frameworks.git 149 | :tag: 8.11.0 150 | 151 | SPEC CHECKSUMS: 152 | cloud_firestore: c6c42fe62809b7417aa3c45a6ef0c2812f7fb0d6 153 | cloud_functions: 8415560122ac43e9edc2efd070ae14e664aa2fd3 154 | Firebase: 44dd9724c84df18b486639e874f31436eaa9a20c 155 | firebase_auth: bdfbd5b10da1db6d5eb6ae7dbda5d81365b9cc9d 156 | firebase_core: 08f6a85f62060111de5e98d6a214810d11365de9 157 | firebase_storage: 5b964cad5f351e9c35f8b0e0b878cdd095f30d09 158 | FirebaseAuth: d96d73aba85d192d7a7aa0b86dd6d7f8ec170b4b 159 | FirebaseCore: 2f4f85b453cc8fea4bb2b37e370007d2bcafe3f0 160 | FirebaseCoreDiagnostics: fd0c8490f34287229c1d6c103d3a55f81ec85712 161 | FirebaseFirestore: 8a0c6a06219bbaad86c72bcb66688c28995dde84 162 | FirebaseFunctions: 2bad3e4365dee72a85a6baa6ccd684f024d14696 163 | FirebaseStorage: 4d05cb1112ff8822a0f9f5090da8bd6d550602ec 164 | Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a 165 | GoogleDataTransport: 629c20a4d363167143f30ea78320d5a7eb8bd940 166 | GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1 167 | GTMSessionFetcher: 4577a4cc914a5a07c40a8a0ad0acc22080418c2d 168 | image_picker: 541dcbb3b9cf32d87eacbd957845d8651d6c62c3 169 | mono_kit: 67c15c1486e232d7f44ac47286933e80aa02f7a3 170 | nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 171 | PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58 172 | url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de 173 | 174 | PODFILE CHECKSUM: 3cd06e8e30c6bd098d387c1b6efa651572bdad99 175 | 176 | COCOAPODS: 1.11.3 177 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/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. -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/GoogleService-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLIENT_ID 6 | 411503049546-q5vegmho0pa0gnig8rmo92n04scr950i.apps.googleusercontent.com 7 | REVERSED_CLIENT_ID 8 | com.googleusercontent.apps.411503049546-q5vegmho0pa0gnig8rmo92n04scr950i 9 | ANDROID_CLIENT_ID 10 | 411503049546-fdeqtjv1jl7cjkkvn8sgi02limetqjh5.apps.googleusercontent.com 11 | API_KEY 12 | AIzaSyC1cRlErkR2IFkaHdfhjFPARNQC02XCefU 13 | GCM_SENDER_ID 14 | 411503049546 15 | PLIST_VERSION 16 | 1 17 | BUNDLE_ID 18 | com.example.example 19 | PROJECT_ID 20 | fir-fir-mono 21 | STORAGE_BUCKET 22 | fir-fir-mono.appspot.com 23 | IS_ADS_ENABLED 24 | 25 | IS_ANALYTICS_ENABLED 26 | 27 | IS_APPINVITE_ENABLED 28 | 29 | IS_GCM_ENABLED 30 | 31 | IS_SIGNIN_ENABLED 32 | 33 | GOOGLE_APP_ID 34 | 1:411503049546:ios:2fd66156364836ac38dfb3 35 | DATABASE_URL 36 | https://fir-fir-mono.firebaseio.com 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 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 | 47 | 48 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/model/service/authenticator.dart'; 2 | import 'package:example/router.dart'; 3 | import 'package:flutter/material.dart' hide Router; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | import 'package:mono_kit/mono_kit.dart'; 6 | 7 | class App extends ConsumerWidget { 8 | const App({super.key}); 9 | @override 10 | Widget build(BuildContext context, WidgetRef ref) { 11 | ref.watch(signInAnonymouslyProvider); 12 | final isSignedIn = ref.watch(isSignedInProvider).value ?? false; 13 | final router = ref.watch(routerProvider); 14 | return !isSignedIn 15 | ? const Center(child: CircularProgressIndicator()) 16 | : MaterialApp.router( 17 | title: ref.watch(appInfo).title, 18 | theme: lightTheme().copyWith( 19 | dividerColor: Colors.black54, 20 | ), 21 | darkTheme: darkTheme(), 22 | routeInformationParser: router.routeInformationParser, 23 | routerDelegate: router.routerDelegate, 24 | routeInformationProvider: router.routeInformationProvider, 25 | ); 26 | } 27 | } 28 | 29 | final appInfo = Provider((_) => AppInfo()); 30 | 31 | class AppInfo { 32 | String get title => 'firestore_ref example'; 33 | } 34 | -------------------------------------------------------------------------------- /example/lib/firebase_options.dart: -------------------------------------------------------------------------------- 1 | // File generated by FlutterFire CLI. 2 | // ignore_for_file: type=lint 3 | import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; 4 | import 'package:flutter/foundation.dart' 5 | show defaultTargetPlatform, kIsWeb, TargetPlatform; 6 | 7 | /// Default [FirebaseOptions] for use with your Firebase apps. 8 | /// 9 | /// Example: 10 | /// ```dart 11 | /// import 'firebase_options.dart'; 12 | /// // ... 13 | /// await Firebase.initializeApp( 14 | /// options: DefaultFirebaseOptions.currentPlatform, 15 | /// ); 16 | /// ``` 17 | class DefaultFirebaseOptions { 18 | static FirebaseOptions get currentPlatform { 19 | if (kIsWeb) { 20 | return web; 21 | } 22 | switch (defaultTargetPlatform) { 23 | case TargetPlatform.android: 24 | return android; 25 | case TargetPlatform.iOS: 26 | return ios; 27 | case TargetPlatform.macOS: 28 | return macos; 29 | case TargetPlatform.windows: 30 | return windows; 31 | case TargetPlatform.linux: 32 | throw UnsupportedError( 33 | 'DefaultFirebaseOptions have not been configured for linux - ' 34 | 'you can reconfigure this by running the FlutterFire CLI again.', 35 | ); 36 | default: 37 | throw UnsupportedError( 38 | 'DefaultFirebaseOptions are not supported for this platform.', 39 | ); 40 | } 41 | } 42 | 43 | static const FirebaseOptions web = FirebaseOptions( 44 | apiKey: 'AIzaSyAjXjl92rq2LrMpJAOV_LYnX-4p2sqlcHk', 45 | appId: '1:411503049546:web:3f41ceee03b1020038dfb3', 46 | messagingSenderId: '411503049546', 47 | projectId: 'fir-fir-mono', 48 | authDomain: 'fir-fir-mono.firebaseapp.com', 49 | databaseURL: 'https://fir-fir-mono.firebaseio.com', 50 | storageBucket: 'fir-fir-mono.appspot.com', 51 | measurementId: 'G-Z4BLYS3KF7', 52 | ); 53 | 54 | static const FirebaseOptions android = FirebaseOptions( 55 | apiKey: 'AIzaSyC68jwLKzJ8E61j40yCwRQeGeVIm4nO0kk', 56 | appId: '1:411503049546:android:1d02260d28cada9c38dfb3', 57 | messagingSenderId: '411503049546', 58 | projectId: 'fir-fir-mono', 59 | databaseURL: 'https://fir-fir-mono.firebaseio.com', 60 | storageBucket: 'fir-fir-mono.appspot.com', 61 | ); 62 | 63 | static const FirebaseOptions ios = FirebaseOptions( 64 | apiKey: 'AIzaSyC1cRlErkR2IFkaHdfhjFPARNQC02XCefU', 65 | appId: '1:411503049546:ios:2fd66156364836ac38dfb3', 66 | messagingSenderId: '411503049546', 67 | projectId: 'fir-fir-mono', 68 | databaseURL: 'https://fir-fir-mono.firebaseio.com', 69 | storageBucket: 'fir-fir-mono.appspot.com', 70 | androidClientId: '411503049546-fdeqtjv1jl7cjkkvn8sgi02limetqjh5.apps.googleusercontent.com', 71 | iosClientId: '411503049546-q5vegmho0pa0gnig8rmo92n04scr950i.apps.googleusercontent.com', 72 | iosBundleId: 'com.example.example', 73 | ); 74 | 75 | static const FirebaseOptions macos = FirebaseOptions( 76 | apiKey: 'AIzaSyC1cRlErkR2IFkaHdfhjFPARNQC02XCefU', 77 | appId: '1:411503049546:ios:2fd66156364836ac38dfb3', 78 | messagingSenderId: '411503049546', 79 | projectId: 'fir-fir-mono', 80 | databaseURL: 'https://fir-fir-mono.firebaseio.com', 81 | storageBucket: 'fir-fir-mono.appspot.com', 82 | androidClientId: '411503049546-fdeqtjv1jl7cjkkvn8sgi02limetqjh5.apps.googleusercontent.com', 83 | iosClientId: '411503049546-q5vegmho0pa0gnig8rmo92n04scr950i.apps.googleusercontent.com', 84 | iosBundleId: 'com.example.example', 85 | ); 86 | 87 | static const FirebaseOptions windows = FirebaseOptions( 88 | apiKey: 'AIzaSyAjXjl92rq2LrMpJAOV_LYnX-4p2sqlcHk', 89 | appId: '1:411503049546:web:3f41ceee03b1020038dfb3', 90 | messagingSenderId: '411503049546', 91 | projectId: 'fir-fir-mono', 92 | authDomain: 'fir-fir-mono.firebaseapp.com', 93 | databaseURL: 'https://fir-fir-mono.firebaseio.com', 94 | storageBucket: 'fir-fir-mono.appspot.com', 95 | measurementId: 'G-Z4BLYS3KF7', 96 | ); 97 | } 98 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | // import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart'; 2 | import 'package:cloud_functions/cloud_functions.dart'; 3 | import 'package:example/firebase_options.dart'; 4 | import 'package:firebase_auth/firebase_auth.dart'; 5 | import 'package:firebase_core/firebase_core.dart'; 6 | import 'package:firebase_storage/firebase_storage.dart'; 7 | import 'package:firestore_ref/firestore_ref.dart'; 8 | import 'package:flutter/foundation.dart'; 9 | import 'package:flutter/material.dart'; 10 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 11 | 12 | import 'app.dart'; 13 | import 'util/util.dart'; 14 | 15 | Future main() async { 16 | const isEmulator = bool.fromEnvironment('IS_EMULATOR'); 17 | logger.fine('start(isEmulator: $isEmulator)'); 18 | 19 | firestoreOperationCounter.enabled = true; 20 | 21 | WidgetsFlutterBinding.ensureInitialized(); 22 | await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); 23 | 24 | if (isEmulator) { 25 | const localhost = 'localhost'; 26 | FirebaseFunctions.instance.useFunctionsEmulator(localhost, 5001); 27 | FirebaseFirestore.instance.useFirestoreEmulator(localhost, 8080); 28 | await Future.wait( 29 | [ 30 | FirebaseAuth.instance.useAuthEmulator(localhost, 9099), 31 | FirebaseStorage.instance.useStorageEmulator(localhost, 9199), 32 | ], 33 | ); 34 | FirebaseFirestore.instance.settings = const Settings( 35 | persistenceEnabled: false, 36 | ); 37 | } else if (kIsWeb) { 38 | FirebaseFirestore.instance.settings = const Settings( 39 | persistenceEnabled: true, 40 | ); 41 | } 42 | 43 | runApp( 44 | const ProviderScope( 45 | child: App(), 46 | ), 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /example/lib/model/firestore/firestore.dart: -------------------------------------------------------------------------------- 1 | export 'user/user.dart'; 2 | -------------------------------------------------------------------------------- /example/lib/model/firestore/user/user.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart' hide count; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:freezed_annotation/freezed_annotation.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | import 'package:json_converter_helper/json_converter_helper.dart'; 6 | 7 | part 'user.freezed.dart'; 8 | part 'user.g.dart'; 9 | 10 | final usersRefProvider = Provider((ref) => UsersRef()); 11 | 12 | @freezed 13 | class User with _$User { 14 | @allJsonConvertersSerializable 15 | const factory User({ 16 | @Default(0) int count, 17 | @Default(UnionTimestamp.serverTimestamp()) UnionTimestamp createdAt, 18 | @UnionTimestampConverter.alwaysServerTimestampConverter 19 | @Default(UnionTimestamp.serverTimestamp()) 20 | UnionTimestamp updatedAt, 21 | }) = _User; 22 | factory User.fromJson(JsonMap json) => _$UserFromJson(json); 23 | 24 | const User._(); 25 | 26 | User incremented() => copyWith(count: count + 1); 27 | } 28 | 29 | class UserField { 30 | static const count = 'count'; 31 | } 32 | 33 | class UsersRef extends CollectionRef { 34 | UsersRef() : super(FirebaseFirestore.instance.collection('users')); 35 | 36 | @override 37 | JsonMap encode(User data) => data.toJson(); 38 | 39 | @override 40 | UserDoc decode(DocumentSnapshot snapshot, UserRef docRef) { 41 | return UserDoc( 42 | docRef, 43 | User.fromJson(snapshot.data()!), 44 | ); 45 | } 46 | 47 | @override 48 | UserRef docRef(DocumentReference ref) => UserRef( 49 | ref: ref, 50 | usersRef: this, 51 | ); 52 | } 53 | 54 | class UserRef extends DocumentRef { 55 | const UserRef({ 56 | required super.ref, 57 | required this.usersRef, 58 | }) : super( 59 | collectionRef: usersRef, 60 | ); 61 | 62 | final UsersRef usersRef; 63 | } 64 | 65 | class UserDoc extends Document { 66 | const UserDoc( 67 | this.userRef, 68 | User? entity, 69 | ) : super(userRef, entity); 70 | 71 | final UserRef userRef; 72 | } 73 | -------------------------------------------------------------------------------- /example/lib/model/firestore/user/user.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | // ignore_for_file: type=lint, implicit_dynamic_parameter, implicit_dynamic_type, implicit_dynamic_method, strict_raw_type, unused_field, unused_element 4 | 5 | part of 'user.dart'; 6 | 7 | // ************************************************************************** 8 | // JsonSerializableGenerator 9 | // ************************************************************************** 10 | 11 | _$UserImpl _$$UserImplFromJson(Map json) => _$UserImpl( 12 | count: (json['count'] as num?)?.toInt() ?? 0, 13 | createdAt: json['createdAt'] == null 14 | ? const UnionTimestamp.serverTimestamp() 15 | : const UnionTimestampConverter() 16 | .fromJson(json['createdAt'] as Object), 17 | updatedAt: json['updatedAt'] == null 18 | ? const UnionTimestamp.serverTimestamp() 19 | : UnionTimestampConverter.alwaysServerTimestampConverter 20 | .fromJson(json['updatedAt'] as Object), 21 | ); 22 | 23 | abstract final class _$$UserImplJsonKeys { 24 | static const String count = 'count'; 25 | static const String createdAt = 'createdAt'; 26 | static const String updatedAt = 'updatedAt'; 27 | } 28 | 29 | Map _$$UserImplToJson(_$UserImpl instance) => 30 | { 31 | 'count': instance.count, 32 | 'createdAt': const UnionTimestampConverter().toJson(instance.createdAt), 33 | 'updatedAt': UnionTimestampConverter.alwaysServerTimestampConverter 34 | .toJson(instance.updatedAt), 35 | }; 36 | -------------------------------------------------------------------------------- /example/lib/model/service/authenticator.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/model/firestore/firestore.dart'; 2 | import 'package:firebase_auth/firebase_auth.dart' as auth; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | final _authProvider = Provider((_) => auth.FirebaseAuth.instance); 6 | 7 | final authUserProvider = StreamProvider( 8 | (ref) => ref.watch(_authProvider).userChanges(), 9 | ); 10 | 11 | final userIdProvider = Provider( 12 | (ref) => ref.watch(authUserProvider).whenData((user) => user?.uid), 13 | ); 14 | 15 | final isSignedInProvider = Provider( 16 | (ref) => ref.watch(userIdProvider).whenData((id) => id != null), 17 | ); 18 | 19 | final signInAnonymouslyProvider = FutureProvider( 20 | (ref) => ref.watch(_authProvider).signInAnonymously(), 21 | ); 22 | 23 | final myUserRefProvider = Provider( 24 | (ref) { 25 | final userId = ref.watch(userIdProvider); 26 | final usersRef = ref.watch(usersRefProvider); 27 | return userId.whenData(usersRef.docRefWithId); 28 | }, 29 | ); 30 | 31 | final _myUserDocProvider = StreamProvider.autoDispose( 32 | (ref) => ref.watch(myUserRefProvider).value?.document() ?? Stream.value(null), 33 | ); 34 | 35 | final myUserDocProvider = Provider.autoDispose( 36 | (ref) { 37 | final doc = ref.watch(_myUserDocProvider).value; 38 | return ref.watch(myUserRefProvider).whenData( 39 | (userRef) => 40 | doc ?? 41 | UserDoc( 42 | userRef, 43 | const User(), 44 | ), 45 | ); 46 | }, 47 | ); 48 | 49 | final myCountProvider = Provider.autoDispose( 50 | (ref) => ref.watch(myUserDocProvider).whenData((doc) => doc.entity?.count), 51 | ); 52 | -------------------------------------------------------------------------------- /example/lib/model/service/count_incrementer.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/model/firestore/firestore.dart'; 2 | import 'package:example/model/service/service.dart'; 3 | import 'package:example/pages/user_counter_page.dart'; 4 | import 'package:example/util/util.dart'; 5 | import 'package:firestore_ref/firestore_ref.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | final countIncrementer = Provider( 9 | (ref) { 10 | final read = ref.read; 11 | return () { 12 | final updateType = read(selectedUpdateType); 13 | logger.info('updateType: $updateType'); 14 | final doc = read(myUserDocProvider).value; 15 | if (doc == null) { 16 | throw AssertionError('_doc should not be null'); 17 | } 18 | final user = doc.entity; 19 | if (user == null) { 20 | throw AssertionError('_doc.user should not be null'); 21 | } 22 | final ref = doc.userRef; 23 | switch (updateType) { 24 | case UpdateType.add: 25 | ref.merge(user.incremented()); 26 | case UpdateType.increment: 27 | ref.mergeData( 28 | ref.collectionRef.encode(user) 29 | ..[UserField.count] = FieldValue.increment(1), 30 | ); 31 | case UpdateType.batch: 32 | runBatchWrite((batch) { 33 | return ref.merge( 34 | user.incremented(), 35 | batch: batch, 36 | ); 37 | }); 38 | case UpdateType.transaction: 39 | FirebaseFirestore.instance.runTransaction((transaction) { 40 | return ref.update( 41 | user.incremented(), 42 | transaction: transaction, 43 | ); 44 | }); 45 | } 46 | }; 47 | }, 48 | ); 49 | -------------------------------------------------------------------------------- /example/lib/model/service/service.dart: -------------------------------------------------------------------------------- 1 | export 'authenticator.dart'; 2 | export 'count_incrementer.dart'; 3 | export 'user_docs_provider.dart'; 4 | export 'users_deleter.dart'; 5 | -------------------------------------------------------------------------------- /example/lib/model/service/user_docs_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/model/firestore/firestore.dart'; 2 | import 'package:firestore_ref/firestore_ref.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | final userDocsProvider = StreamProvider( 6 | (ref) => ref.watch(usersRefProvider).documents( 7 | (r) => r 8 | .orderBy( 9 | TimestampField.updatedAt, 10 | descending: true, 11 | ) 12 | .limit(100), 13 | ), 14 | ); 15 | -------------------------------------------------------------------------------- /example/lib/model/service/users_deleter.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/model/firestore/firestore.dart'; 2 | import 'package:example/util/util.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | final usersDeleter = Provider((ref) { 6 | final read = ref.read; 7 | return () async { 8 | logger.info('[Start] deleteAll'); 9 | final deletedIds = await read(usersRefProvider).deleteAllDocuments( 10 | batchSize: 2, 11 | ); 12 | logger 13 | ..info('[End] deleteAll') 14 | ..info('Deleted ids: $deletedIds'); 15 | }; 16 | }); 17 | -------------------------------------------------------------------------------- /example/lib/pages/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/app.dart'; 2 | import 'package:example/router.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | 7 | class HomePage extends ConsumerWidget { 8 | const HomePage({super.key}); 9 | @override 10 | Widget build(BuildContext context, WidgetRef ref) { 11 | return Scaffold( 12 | appBar: AppBar( 13 | title: Text(ref.watch(appInfo).title), 14 | ), 15 | body: ListView( 16 | children: PageInfo.all.map((info) { 17 | final routeName = info.routeName; 18 | return ListTile( 19 | title: Text(pascalCaseFromRouteName(routeName)), 20 | trailing: const Icon(Icons.chevron_right), 21 | onTap: () => GoRouter.of(context).goNamed(routeName), 22 | ); 23 | }).toList(), 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/lib/pages/paging_page/paging_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:freezed_annotation/freezed_annotation.dart'; 4 | import 'package:json_converter_helper/json_converter_helper.dart'; 5 | 6 | part 'paging_data.freezed.dart'; 7 | part 'paging_data.g.dart'; 8 | 9 | @freezed 10 | class PagingData with _$PagingData { 11 | @allJsonConvertersSerializable 12 | const factory PagingData({ 13 | @Default(0) int count, 14 | @Default(UnionTimestamp.serverTimestamp()) UnionTimestamp createdAt, 15 | @UnionTimestampConverter.alwaysServerTimestampConverter 16 | @Default(UnionTimestamp.serverTimestamp()) 17 | UnionTimestamp updatedAt, 18 | }) = _PagingData; 19 | factory PagingData.fromJson(JsonMap json) => _$PagingDataFromJson(json); 20 | } 21 | 22 | class PagingDataDoc extends Document { 23 | const PagingDataDoc( 24 | this.pagingDataRef, 25 | PagingData entity, 26 | ) : super(pagingDataRef, entity); 27 | 28 | final PagingDataRef pagingDataRef; 29 | } 30 | 31 | class PagingDatasRef 32 | extends CollectionRef { 33 | PagingDatasRef() 34 | : super( 35 | FirebaseFirestore.instance.collection('pagings'), 36 | ); 37 | 38 | @override 39 | PagingDataRef docRef(DocumentReference ref) { 40 | return PagingDataRef( 41 | ref: ref, 42 | collectionRef: this, 43 | ); 44 | } 45 | 46 | @override 47 | PagingDataDoc decode( 48 | DocumentSnapshot snapshot, 49 | PagingDataRef docRef, 50 | ) { 51 | return PagingDataDoc( 52 | docRef, 53 | PagingData.fromJson(snapshot.data()!), 54 | ); 55 | } 56 | 57 | @override 58 | JsonMap encode(PagingData data) => data.toJson(); 59 | } 60 | 61 | class PagingDataRef extends DocumentRef { 62 | const PagingDataRef({ 63 | required super.ref, 64 | required PagingDatasRef collectionRef, 65 | }) : super( 66 | collectionRef: collectionRef, 67 | ); 68 | } 69 | -------------------------------------------------------------------------------- /example/lib/pages/paging_page/paging_data.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | // ignore_for_file: type=lint, implicit_dynamic_parameter, implicit_dynamic_type, implicit_dynamic_method, strict_raw_type, unused_field, unused_element 4 | 5 | part of 'paging_data.dart'; 6 | 7 | // ************************************************************************** 8 | // JsonSerializableGenerator 9 | // ************************************************************************** 10 | 11 | _$PagingDataImpl _$$PagingDataImplFromJson(Map json) => _$PagingDataImpl( 12 | count: (json['count'] as num?)?.toInt() ?? 0, 13 | createdAt: json['createdAt'] == null 14 | ? const UnionTimestamp.serverTimestamp() 15 | : const UnionTimestampConverter() 16 | .fromJson(json['createdAt'] as Object), 17 | updatedAt: json['updatedAt'] == null 18 | ? const UnionTimestamp.serverTimestamp() 19 | : UnionTimestampConverter.alwaysServerTimestampConverter 20 | .fromJson(json['updatedAt'] as Object), 21 | ); 22 | 23 | abstract final class _$$PagingDataImplJsonKeys { 24 | static const String count = 'count'; 25 | static const String createdAt = 'createdAt'; 26 | static const String updatedAt = 'updatedAt'; 27 | } 28 | 29 | Map _$$PagingDataImplToJson(_$PagingDataImpl instance) => 30 | { 31 | 'count': instance.count, 32 | 'createdAt': const UnionTimestampConverter().toJson(instance.createdAt), 33 | 'updatedAt': UnionTimestampConverter.alwaysServerTimestampConverter 34 | .toJson(instance.updatedAt), 35 | }; 36 | -------------------------------------------------------------------------------- /example/lib/pages/paging_page/paging_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router.dart'; 2 | import 'package:example/util/util.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | 6 | import 'paging_page_controller.dart'; 7 | 8 | class PagingPage extends ConsumerWidget { 9 | const PagingPage({super.key}); 10 | 11 | static const routeName = 'paging'; 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | return Scaffold( 16 | appBar: AppBar( 17 | title: Text( 18 | pascalCaseFromRouteName(routeName), 19 | ), 20 | actions: const [ 21 | _DropdownButton(), 22 | ], 23 | ), 24 | floatingActionButton: FloatingActionButton.extended( 25 | onPressed: () => ref.read(pagingDocsModifier).addDocs(10), 26 | label: const Text('10 DATA'), 27 | icon: const Icon(Icons.add), 28 | ), 29 | body: Column( 30 | children: [ 31 | ListTile( 32 | title: Center( 33 | child: Text(ref.watch(pagingPageInfoProvider)), 34 | ), 35 | ), 36 | const Divider(height: 0), 37 | const Expanded( 38 | child: _ListView(), 39 | ), 40 | ], 41 | ), 42 | ); 43 | } 44 | } 45 | 46 | class _ListView extends ConsumerWidget { 47 | const _ListView(); 48 | @override 49 | Widget build(BuildContext context, WidgetRef ref) { 50 | final controller = ref.watch(pagingController); 51 | final docs = ref.watch(documentsProvider).value ?? []; 52 | final count = ref.watch(pagingDocsLengthForWidgetProvider); 53 | final theme = Theme.of(context); 54 | final colorScheme = theme.colorScheme; 55 | return ListView.builder( 56 | itemCount: count, 57 | itemBuilder: (context, index) { 58 | if (index >= docs.length) { 59 | controller.loadMore(); 60 | return const ListTile( 61 | title: Center(child: CircularProgressIndicator.adaptive()), 62 | ); 63 | } 64 | final doc = docs[index]; 65 | return ListTile( 66 | title: Text('${doc.entity!.count}'), 67 | trailing: IconButton( 68 | color: colorScheme.secondary, 69 | icon: const Icon(Icons.add), 70 | onPressed: () => ref.read(pagingDocsModifier).increment(doc: doc), 71 | ), 72 | ); 73 | }, 74 | ); 75 | } 76 | } 77 | 78 | class _DropdownButton extends ConsumerWidget { 79 | const _DropdownButton(); 80 | @override 81 | Widget build(BuildContext context, WidgetRef ref) { 82 | final theme = Theme.of(context); 83 | final colorScheme = theme.colorScheme; 84 | return PopupMenuButton( 85 | itemBuilder: (context) => [ 86 | PopupMenuItem( 87 | value: 'deleteAll', 88 | child: Text( 89 | 'Delete All', 90 | style: TextStyle( 91 | color: colorScheme.error, 92 | ), 93 | ), 94 | ), 95 | ], 96 | onSelected: (value) { 97 | logger.info(value); 98 | ref.read(pagingDocsModifier).deleteAll(); 99 | }, 100 | ); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /example/lib/pages/paging_page/paging_page_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/pages/paging_page/paging_data.dart'; 2 | import 'package:example/util/util.dart'; 3 | import 'package:firestore_ref/firestore_ref.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | 6 | final pagingCollectionRef = Provider((ref) => PagingDatasRef()); 7 | 8 | final pagingController = Provider.autoDispose( 9 | (ref) { 10 | final controller = ref.watch(pagingCollectionRef).pagingController( 11 | queryBuilder: (r) => r.orderBy('createdAt'), 12 | initialSize: 20, 13 | defaultPagingSize: 10, 14 | ); 15 | ref.onDispose(controller.dispose); 16 | return controller; 17 | }, 18 | ); 19 | 20 | // TODO(mono): 過去に偶然動いてた部分が動かなくなったのを無理矢理対処したので https://github.com/mono0926/flutter_playground/blob/main/lib/paging/paging/paging_notifier.dart のようにCollectionPagingControllerを直したい 21 | final documentsProvider = StreamProvider.autoDispose( 22 | (ref) => ref.watch(pagingController).documents, 23 | ); 24 | 25 | final pagingDocsLengthProvider = Provider.autoDispose( 26 | (ref) => ref.watch(documentsProvider).value?.length ?? 0, 27 | ); 28 | 29 | final pagingDocsLengthForWidgetProvider = Provider.autoDispose( 30 | (ref) { 31 | final hasMore = ref.watch(pagingController.select((s) => s.hasMore)).value; 32 | return ref.watch(pagingDocsLengthProvider) + (hasMore ? 1 : 0); 33 | }, 34 | ); 35 | 36 | final pagingDocsModifier = Provider(PagingDocsModifier.new); 37 | 38 | class PagingDocsModifier { 39 | PagingDocsModifier(this._ref); 40 | 41 | final Ref _ref; 42 | 43 | void addDocs(int count) { 44 | runBatchWrite((batch) async { 45 | for (var i = 0; i < count; i++) { 46 | await _ref.read(pagingCollectionRef).docRefWithId().set( 47 | const PagingData(), 48 | batch: batch, 49 | ); 50 | } 51 | }); 52 | } 53 | 54 | void increment({required PagingDataDoc doc}) { 55 | final data = doc.entity!; 56 | doc.pagingDataRef.merge( 57 | data.copyWith( 58 | count: data.count + 1, 59 | ), 60 | ); 61 | } 62 | 63 | Future deleteAll() async { 64 | logger.info('[Start] deleteAll'); 65 | final deletedIds = 66 | await _ref.read(pagingCollectionRef).deleteAllDocuments(); 67 | logger 68 | ..info('[End] deleteAll') 69 | ..info('Deleted ids: $deletedIds'); 70 | } 71 | } 72 | 73 | final pagingPageInfoProvider = Provider.autoDispose((ref) { 74 | final length = ref.watch(pagingDocsLengthProvider); 75 | final hasMore = ref.watch(pagingController.select((s) => s.hasMore)).value; 76 | return '$length / ${hasMore ? '?' : length}'; 77 | }); 78 | -------------------------------------------------------------------------------- /example/lib/pages/user_counter_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/model/service/service.dart'; 2 | import 'package:example/router.dart'; 3 | import 'package:example/util/util.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | class UserCounterPage extends ConsumerWidget { 9 | const UserCounterPage({super.key}); 10 | 11 | static const routeName = 'user_counter'; 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final updateType = ref.watch(selectedUpdateType); 16 | return Scaffold( 17 | appBar: AppBar( 18 | title: Text( 19 | pascalCaseFromRouteName(routeName), 20 | ), 21 | actions: const [ 22 | _DropdownButton(), 23 | ], 24 | ), 25 | body: Column( 26 | children: [ 27 | Padding( 28 | padding: const EdgeInsets.symmetric(vertical: 16), 29 | child: CupertinoSlidingSegmentedControl( 30 | children: const { 31 | UpdateType.add: Text('Add'), 32 | UpdateType.increment: Text('Incr'), 33 | UpdateType.batch: Text('Batch'), 34 | UpdateType.transaction: Text('Tran'), 35 | }, 36 | onValueChanged: (type) => ref 37 | .read(selectedUpdateType.notifier) 38 | .update((state) => type!), 39 | groupValue: updateType, 40 | ), 41 | ), 42 | const Divider(height: 0), 43 | const _AccountStatus(), 44 | const _MyCounter(), 45 | const Divider(), 46 | const Expanded( 47 | child: _Users(), 48 | ), 49 | ], 50 | ), 51 | ); 52 | } 53 | } 54 | 55 | class _DropdownButton extends ConsumerWidget { 56 | const _DropdownButton(); 57 | @override 58 | Widget build(BuildContext context, WidgetRef ref) { 59 | final theme = Theme.of(context); 60 | final colorScheme = theme.colorScheme; 61 | return PopupMenuButton( 62 | itemBuilder: (context) => [ 63 | PopupMenuItem( 64 | value: 'deleteAll', 65 | child: Text( 66 | 'Delete All', 67 | style: TextStyle( 68 | color: colorScheme.error, 69 | ), 70 | ), 71 | ), 72 | ], 73 | onSelected: (value) { 74 | logger.info(value); 75 | ref.read(usersDeleter)(); 76 | }, 77 | ); 78 | } 79 | } 80 | 81 | class _AccountStatus extends ConsumerWidget { 82 | const _AccountStatus(); 83 | @override 84 | Widget build(BuildContext context, WidgetRef ref) { 85 | return ListTile( 86 | title: const Text('User ID'), 87 | subtitle: Text( 88 | ref.watch(userIdProvider.select((id) => id.value ?? '-')), 89 | ), 90 | ); 91 | } 92 | } 93 | 94 | class _MyCounter extends ConsumerWidget { 95 | const _MyCounter(); 96 | 97 | @override 98 | Widget build(BuildContext context, WidgetRef ref) { 99 | return ListTile( 100 | title: const Text('My Count'), 101 | subtitle: Text('${ref.watch(myCountProvider)}'), 102 | trailing: IconButton( 103 | color: Theme.of(context).primaryColor, 104 | icon: const Icon(Icons.add), 105 | onPressed: () { 106 | ref.read(countIncrementer)(); 107 | // 適当にどこかで雑に呼びたかっただけでサンプルとは関係なし(無視してください) 108 | // final result = await FirebaseFunctions.instance 109 | // .httpsCallable('now') 110 | // .call(); 111 | // logger.info(result.data); 112 | }, 113 | ), 114 | ); 115 | } 116 | } 117 | 118 | class _Users extends ConsumerWidget { 119 | const _Users(); 120 | @override 121 | Widget build(BuildContext context, WidgetRef ref) { 122 | final docs = ref.watch(userDocsProvider).value ?? []; 123 | final myId = ref.watch(userIdProvider).value; 124 | return ListView.builder( 125 | itemBuilder: (context, index) { 126 | final doc = docs[index]; 127 | // ignore: use_colored_box 128 | return Container( 129 | key: ValueKey(doc.id), 130 | color: myId == doc.id ? Colors.green[100] : null, 131 | child: ListTile( 132 | title: Text(doc.id), 133 | subtitle: Text('count: ${doc.entity!.count}'), 134 | ), 135 | ); 136 | }, 137 | itemCount: docs.length, 138 | ); 139 | } 140 | } 141 | 142 | final selectedUpdateType = StateProvider((ref) => UpdateType.add); 143 | 144 | enum UpdateType { 145 | add, 146 | increment, 147 | batch, 148 | transaction, 149 | } 150 | -------------------------------------------------------------------------------- /example/lib/router.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/pages/home_page.dart'; 2 | import 'package:example/pages/paging_page/paging_page.dart'; 3 | import 'package:example/pages/user_counter_page.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:go_router/go_router.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | import 'package:mono_kit/mono_kit.dart'; 8 | import 'package:recase/recase.dart'; 9 | 10 | typedef WidgetPageBuilder = Widget Function(); 11 | 12 | final routerProvider = Provider( 13 | (_) => GoRouter( 14 | routes: [ 15 | ShellRoute( 16 | builder: goRouteLocationButtonNavigationBuilder, 17 | routes: [ 18 | GoRoute( 19 | path: '/', 20 | builder: (_, __) => const HomePage(), 21 | routes: [ 22 | GoRoute( 23 | path: 'user-counter', 24 | name: UserCounterPage.routeName, 25 | builder: (_, __) => const UserCounterPage(), 26 | ), 27 | GoRoute( 28 | path: 'paging', 29 | name: PagingPage.routeName, 30 | builder: (_, __) => const PagingPage(), 31 | ), 32 | ], 33 | ), 34 | ], 35 | ), 36 | ], 37 | ), 38 | ); 39 | 40 | String pascalCaseFromRouteName(String name) => name.pascalCase; 41 | 42 | @immutable 43 | class PageInfo { 44 | const PageInfo({ 45 | required this.routeName, 46 | }); 47 | 48 | final String routeName; 49 | 50 | static const all = [ 51 | PageInfo(routeName: UserCounterPage.routeName), 52 | PageInfo(routeName: PagingPage.routeName), 53 | ]; 54 | } 55 | -------------------------------------------------------------------------------- /example/lib/util/logger.dart: -------------------------------------------------------------------------------- 1 | import 'package:simple_logger/simple_logger.dart'; 2 | 3 | final logger = SimpleLogger() 4 | ..mode = LoggerMode.print 5 | ..setLevel( 6 | Level.FINEST, 7 | includeCallerInfo: true, 8 | ); 9 | -------------------------------------------------------------------------------- /example/lib/util/util.dart: -------------------------------------------------------------------------------- 1 | export 'logger.dart'; 2 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import appkit_ui_element_colors 9 | import cloud_firestore 10 | import cloud_functions 11 | import dynamic_color 12 | import file_selector_macos 13 | import firebase_auth 14 | import firebase_core 15 | import firebase_storage 16 | import macos_ui 17 | import macos_window_utils 18 | import url_launcher_macos 19 | 20 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 21 | AppkitUiElementColorsPlugin.register(with: registry.registrar(forPlugin: "AppkitUiElementColorsPlugin")) 22 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) 23 | FirebaseFunctionsPlugin.register(with: registry.registrar(forPlugin: "FirebaseFunctionsPlugin")) 24 | DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) 25 | FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) 26 | FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) 27 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) 28 | FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin")) 29 | MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin")) 30 | MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) 31 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 32 | } 33 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.15' 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 | # Follow this: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/cloud_firestore/cloud_firestore/ios/cloud_firestore.podspec#L6 34 | pod 'FirebaseFirestore/WithLeveldb', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '@russell/ios-10' 35 | 36 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - cloud_firestore (4.0.4): 3 | - Firebase/CoreOnly (~> 10.0.0) 4 | - Firebase/Firestore (~> 10.0.0) 5 | - firebase_core 6 | - FlutterMacOS 7 | - nanopb (< 2.30910.0, >= 2.30908.0) 8 | - cloud_functions (4.0.3): 9 | - Firebase/CoreOnly (~> 10.0.0) 10 | - Firebase/Functions (~> 10.0.0) 11 | - firebase_core 12 | - FlutterMacOS 13 | - dynamic_color (0.0.2): 14 | - FlutterMacOS 15 | - Firebase/Auth (10.0.0): 16 | - Firebase/CoreOnly 17 | - FirebaseAuth (~> 10.0.0) 18 | - Firebase/CoreOnly (10.0.0): 19 | - FirebaseCore (= 10.0.0) 20 | - Firebase/Firestore (10.0.0): 21 | - Firebase/CoreOnly 22 | - FirebaseFirestore (~> 10.0.0) 23 | - Firebase/Functions (10.0.0): 24 | - Firebase/CoreOnly 25 | - FirebaseFunctions (~> 10.0.0) 26 | - Firebase/Storage (10.0.0): 27 | - Firebase/CoreOnly 28 | - FirebaseStorage (~> 10.0.0) 29 | - firebase_auth (4.1.1): 30 | - Firebase/Auth (~> 10.0.0) 31 | - Firebase/CoreOnly (~> 10.0.0) 32 | - firebase_core 33 | - FlutterMacOS 34 | - firebase_core (2.1.1): 35 | - Firebase/CoreOnly (~> 10.0.0) 36 | - FlutterMacOS 37 | - firebase_storage (11.0.4): 38 | - Firebase/CoreOnly (~> 10.0.0) 39 | - Firebase/Storage (~> 10.0.0) 40 | - firebase_core 41 | - FlutterMacOS 42 | - FirebaseAppCheckInterop (10.1.0) 43 | - FirebaseAuth (10.0.0): 44 | - FirebaseCore (~> 10.0) 45 | - GoogleUtilities/AppDelegateSwizzler (~> 7.8) 46 | - GoogleUtilities/Environment (~> 7.8) 47 | - GTMSessionFetcher/Core (~> 2.1) 48 | - FirebaseAuthInterop (10.1.0) 49 | - FirebaseCore (10.0.0): 50 | - FirebaseCoreInternal (~> 10.0) 51 | - GoogleUtilities/Environment (~> 7.8) 52 | - GoogleUtilities/Logger (~> 7.8) 53 | - FirebaseCoreExtension (10.1.0): 54 | - FirebaseCore (~> 10.0) 55 | - FirebaseCoreInternal (10.1.0): 56 | - "GoogleUtilities/NSData+zlib (~> 7.8)" 57 | - FirebaseFirestore (10.0.0): 58 | - FirebaseFirestore/AutodetectLeveldb (= 10.0.0) 59 | - FirebaseFirestore/AutodetectLeveldb (10.0.0): 60 | - FirebaseFirestore/Base 61 | - FirebaseFirestore/WithLeveldb 62 | - FirebaseFirestore/Base (10.0.0) 63 | - FirebaseFirestore/WithLeveldb (10.0.0): 64 | - FirebaseFirestore/Base 65 | - FirebaseFunctions (10.0.0): 66 | - FirebaseAppCheckInterop (~> 10.0) 67 | - FirebaseAuthInterop (~> 10.0) 68 | - FirebaseCore (~> 10.0) 69 | - FirebaseCoreExtension (~> 10.0) 70 | - FirebaseMessagingInterop (~> 10.0) 71 | - FirebaseSharedSwift (~> 10.0) 72 | - GTMSessionFetcher/Core (~> 2.1) 73 | - FirebaseMessagingInterop (10.1.0) 74 | - FirebaseSharedSwift (10.1.0) 75 | - FirebaseStorage (10.0.0): 76 | - FirebaseAppCheckInterop (~> 10.0) 77 | - FirebaseAuthInterop (~> 10.0) 78 | - FirebaseCore (~> 10.0) 79 | - FirebaseCoreExtension (~> 10.0) 80 | - GTMSessionFetcher/Core (~> 2.1) 81 | - FlutterMacOS (1.0.0) 82 | - GoogleUtilities/AppDelegateSwizzler (7.8.0): 83 | - GoogleUtilities/Environment 84 | - GoogleUtilities/Logger 85 | - GoogleUtilities/Network 86 | - GoogleUtilities/Environment (7.8.0): 87 | - PromisesObjC (< 3.0, >= 1.2) 88 | - GoogleUtilities/Logger (7.8.0): 89 | - GoogleUtilities/Environment 90 | - GoogleUtilities/Network (7.8.0): 91 | - GoogleUtilities/Logger 92 | - "GoogleUtilities/NSData+zlib" 93 | - GoogleUtilities/Reachability 94 | - "GoogleUtilities/NSData+zlib (7.8.0)" 95 | - GoogleUtilities/Reachability (7.8.0): 96 | - GoogleUtilities/Logger 97 | - GTMSessionFetcher/Core (2.2.0) 98 | - macos_ui (0.1.0): 99 | - FlutterMacOS 100 | - nanopb (2.30909.0): 101 | - nanopb/decode (= 2.30909.0) 102 | - nanopb/encode (= 2.30909.0) 103 | - nanopb/decode (2.30909.0) 104 | - nanopb/encode (2.30909.0) 105 | - PromisesObjC (2.1.1) 106 | - url_launcher_macos (0.0.1): 107 | - FlutterMacOS 108 | 109 | DEPENDENCIES: 110 | - cloud_firestore (from `Flutter/ephemeral/.symlinks/plugins/cloud_firestore/macos`) 111 | - cloud_functions (from `Flutter/ephemeral/.symlinks/plugins/cloud_functions/macos`) 112 | - dynamic_color (from `Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos`) 113 | - firebase_auth (from `Flutter/ephemeral/.symlinks/plugins/firebase_auth/macos`) 114 | - firebase_core (from `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`) 115 | - firebase_storage (from `Flutter/ephemeral/.symlinks/plugins/firebase_storage/macos`) 116 | - "FirebaseFirestore/WithLeveldb (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `@russell/ios-10`)" 117 | - FlutterMacOS (from `Flutter/ephemeral`) 118 | - macos_ui (from `Flutter/ephemeral/.symlinks/plugins/macos_ui/macos`) 119 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 120 | 121 | SPEC REPOS: 122 | trunk: 123 | - Firebase 124 | - FirebaseAppCheckInterop 125 | - FirebaseAuth 126 | - FirebaseAuthInterop 127 | - FirebaseCore 128 | - FirebaseCoreExtension 129 | - FirebaseCoreInternal 130 | - FirebaseFunctions 131 | - FirebaseMessagingInterop 132 | - FirebaseSharedSwift 133 | - FirebaseStorage 134 | - GoogleUtilities 135 | - GTMSessionFetcher 136 | - nanopb 137 | - PromisesObjC 138 | 139 | EXTERNAL SOURCES: 140 | cloud_firestore: 141 | :path: Flutter/ephemeral/.symlinks/plugins/cloud_firestore/macos 142 | cloud_functions: 143 | :path: Flutter/ephemeral/.symlinks/plugins/cloud_functions/macos 144 | dynamic_color: 145 | :path: Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos 146 | firebase_auth: 147 | :path: Flutter/ephemeral/.symlinks/plugins/firebase_auth/macos 148 | firebase_core: 149 | :path: Flutter/ephemeral/.symlinks/plugins/firebase_core/macos 150 | firebase_storage: 151 | :path: Flutter/ephemeral/.symlinks/plugins/firebase_storage/macos 152 | FirebaseFirestore: 153 | :git: https://github.com/invertase/firestore-ios-sdk-frameworks.git 154 | :tag: "@russell/ios-10" 155 | FlutterMacOS: 156 | :path: Flutter/ephemeral 157 | macos_ui: 158 | :path: Flutter/ephemeral/.symlinks/plugins/macos_ui/macos 159 | url_launcher_macos: 160 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 161 | 162 | CHECKOUT OPTIONS: 163 | FirebaseFirestore: 164 | :git: https://github.com/invertase/firestore-ios-sdk-frameworks.git 165 | :tag: "@russell/ios-10" 166 | 167 | SPEC CHECKSUMS: 168 | cloud_firestore: 74062ccfd34d272ba0b1c18e3f315e48da5e1ef8 169 | cloud_functions: 6040cfa024f5a9d8217a04f1614bfd2704498792 170 | dynamic_color: 394d6a888650f8534e029b27d2f8bc5c64e44008 171 | Firebase: 1b810f3d0c0532e27a48f1961f8c0400a668a2cf 172 | firebase_auth: 65dab2f61a160cab11d6bbbc4090ee8b1d8a17ed 173 | firebase_core: 2ad407221995257e47215d9ae92467db0dd48ced 174 | firebase_storage: ba73a019ba35178ce2ff26662a8bbccf85847bf7 175 | FirebaseAppCheckInterop: 53eec3c354a95f8fe6ff947dd9518ea17f624914 176 | FirebaseAuth: 493382cf533cc45e2862b00e9aa4cfe4c98daf71 177 | FirebaseAuthInterop: 15b2c717321d5e46a60562e388c4d1b039ea7e28 178 | FirebaseCore: 97f48a3a567a72b8d4daa0f03c3aadb78df4e995 179 | FirebaseCoreExtension: 69b966c399abc4ca6dc75006ab87160f81512725 180 | FirebaseCoreInternal: 96d75228e10fd369564da51bd898414eb0f54df5 181 | FirebaseFirestore: cc7918beafb37938ad111d1eff32060af7619296 182 | FirebaseFunctions: 3e3ae1fba2feab088c9acc043aa0d094e711988b 183 | FirebaseMessagingInterop: 26c3bf82c7697d8fbfb13216541423bc2c93e8fc 184 | FirebaseSharedSwift: 6966c4de41fba13a4270de1e421e6eee2cf90113 185 | FirebaseStorage: 8b0b0630e11b9f3e4a479a26cfccb70ec790ec50 186 | FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 187 | GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7 188 | GTMSessionFetcher: d62ffccea5108bb9e7762ee121ae63bbdd2c6303 189 | macos_ui: 125c911559d646194386d84c017ad6819122e2db 190 | nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 191 | PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb 192 | url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3 193 | 194 | PODFILE CHECKSUM: 8e7e81169e2570c0ebf09dc568f4b9dcece3ed1e 195 | 196 | COCOAPODS: 1.11.3 197 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/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 = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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.client 10 | 11 | com.apple.security.network.server 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/macos/Runner/GoogleService-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLIENT_ID 6 | 411503049546-q5vegmho0pa0gnig8rmo92n04scr950i.apps.googleusercontent.com 7 | REVERSED_CLIENT_ID 8 | com.googleusercontent.apps.411503049546-q5vegmho0pa0gnig8rmo92n04scr950i 9 | ANDROID_CLIENT_ID 10 | 411503049546-fdeqtjv1jl7cjkkvn8sgi02limetqjh5.apps.googleusercontent.com 11 | API_KEY 12 | AIzaSyC1cRlErkR2IFkaHdfhjFPARNQC02XCefU 13 | GCM_SENDER_ID 14 | 411503049546 15 | PLIST_VERSION 16 | 1 17 | BUNDLE_ID 18 | com.example.example 19 | PROJECT_ID 20 | fir-fir-mono 21 | STORAGE_BUCKET 22 | fir-fir-mono.appspot.com 23 | IS_ADS_ENABLED 24 | 25 | IS_ANALYTICS_ENABLED 26 | 27 | IS_APPINVITE_ENABLED 28 | 29 | IS_GCM_ENABLED 30 | 31 | IS_SIGNIN_ENABLED 32 | 33 | GOOGLE_APP_ID 34 | 1:411503049546:ios:2fd66156364836ac38dfb3 35 | DATABASE_URL 36 | https://fir-fir-mono.firebaseio.com 37 | 38 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter application. 3 | version: 1.0.0+1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: ^3.1.0 8 | dependencies: 9 | cloud_firestore: 10 | cloud_functions: 11 | cupertino_icons: 12 | firebase_auth: 13 | firebase_core: 14 | firebase_storage: 15 | firestore_ref: 16 | path: .. 17 | flutter: 18 | sdk: flutter 19 | flutter_hooks: 20 | freezed_annotation: 21 | go_router: 22 | hooks_riverpod: 23 | json_converter_helper: 24 | mono_kit: 25 | recase: 26 | rxdart: 27 | simple_logger: 28 | state_notifier: 29 | subscription_holder: 30 | dev_dependencies: 31 | build_runner: 32 | flutter_test: 33 | sdk: flutter 34 | freezed: 35 | json_serializable: '>=4.6.0' 36 | pedantic_mono: 37 | flutter: 38 | uses-material-design: true 39 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | void main() { 11 | testWidgets('Counter increments smoke test', (tester) async {}); 12 | } 13 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(example LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "example") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /example/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 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | void RegisterPlugins(flutter::PluginRegistry* registry) { 18 | CloudFirestorePluginCApiRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("CloudFirestorePluginCApi")); 20 | DynamicColorPluginCApiRegisterWithRegistrar( 21 | registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); 22 | FileSelectorWindowsRegisterWithRegistrar( 23 | registry->GetRegistrarForPlugin("FileSelectorWindows")); 24 | FirebaseAuthPluginCApiRegisterWithRegistrar( 25 | registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); 26 | FirebaseCorePluginCApiRegisterWithRegistrar( 27 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); 28 | FirebaseStoragePluginCApiRegisterWithRegistrar( 29 | registry->GetRegistrarForPlugin("FirebaseStoragePluginCApi")); 30 | UrlLauncherWindowsRegisterWithRegistrar( 31 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 32 | } 33 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | cloud_firestore 7 | dynamic_color 8 | file_selector_windows 9 | firebase_auth 10 | firebase_core 11 | firebase_storage 12 | url_launcher_windows 13 | ) 14 | 15 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 16 | ) 17 | 18 | set(PLUGIN_BUNDLED_LIBRARIES) 19 | 20 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 22 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 25 | endforeach(plugin) 26 | 27 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 28 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 29 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 30 | endforeach(ffi_plugin) 31 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /example/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 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 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", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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"example", 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_firestore_ref/442324c46af4be1f27076c01659f2e70321068fe/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /lib/firestore_ref.dart: -------------------------------------------------------------------------------- 1 | 2 | export 'package:cloud_firestore/cloud_firestore.dart'; 3 | 4 | export 'src/collection_ref.dart'; 5 | export 'src/document.dart'; 6 | export 'src/document_ref.dart'; 7 | export 'src/firestore_operation_counter.dart'; 8 | export 'src/functions.dart'; 9 | export 'src/timestamp.dart'; 10 | -------------------------------------------------------------------------------- /lib/src/collection_paging_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:disposable_provider/disposable_provider.dart'; 4 | import 'package:firestore_ref/firestore_ref.dart'; 5 | import 'package:flutter/cupertino.dart'; 6 | import 'package:rxdart/rxdart.dart'; 7 | import 'package:subscription_holder/subscription_holder.dart'; 8 | 9 | import 'document_list.dart'; 10 | 11 | class CollectionPagingController, 12 | DocRef extends DocumentRef> with Disposable { 13 | CollectionPagingController({ 14 | required QueryRef queryRef, 15 | @required QueryBuilder? queryBuilder, 16 | required int initialSize, 17 | required this.defaultPagingSize, 18 | }) : _limitController = BehaviorSubject.seeded(initialSize) { 19 | _sh 20 | ..add( 21 | _limitController.stream 22 | .switchMap((limit) { 23 | final documentList = DocumentList( 24 | docRefCreator: queryRef.docRef, 25 | decoder: (snapshot, docRef) { 26 | final cached = _documentsCache[snapshot.reference.path]; 27 | if (cached != null && snapshot.metadata.isFromCache) { 28 | // logger.fine('cache hit (id: ${cached.id})'); 29 | return cached; 30 | } 31 | final doc = queryRef.decode(snapshot, docRef); 32 | _documentsCache[snapshot.reference.path] = doc; 33 | return doc; 34 | }, 35 | ); 36 | return (queryBuilder ?? (q) => q)(queryRef.query) 37 | .limit(limit + 1) 38 | .snapshots() 39 | .map(documentList.applyingSnapshot); 40 | }) 41 | .map((r) => r.list) 42 | .listen(_documentsForHasMoreController.add), 43 | ) 44 | ..add( 45 | _documentsForHasMoreController.listen((docs) { 46 | _hasMoreController.add(docs.length > _limitController.value); 47 | }), 48 | ); 49 | 50 | _documentsForHasMoreController.map((docs) { 51 | final docLength = docs.length; 52 | final size = min(docLength, _limitController.value); 53 | return size == docLength ? docs : docs.take(size).toList(); 54 | }).pipe(_documentsController); 55 | } 56 | 57 | final int defaultPagingSize; 58 | final BehaviorSubject _limitController; 59 | final _sh = SubscriptionHolder(); 60 | 61 | final _documentsForHasMoreController = BehaviorSubject>.seeded([]); 62 | final _documentsController = BehaviorSubject>.seeded([]); 63 | final _hasMoreController = BehaviorSubject.seeded(true); 64 | // After https://github.com/FirebaseExtended/flutterfire/pull/3263 fixed, change key type to DocumentReference 65 | final _documentsCache = {}; 66 | 67 | ValueStream> get documents => _documentsController.stream; 68 | ValueStream get hasMore => _hasMoreController.stream; 69 | 70 | bool loadMore({int? pagingSize}) { 71 | final hasMore = this.hasMore.value; 72 | if (hasMore) { 73 | _limitController.add( 74 | _limitController.value + (pagingSize ?? defaultPagingSize), 75 | ); 76 | } 77 | return hasMore; 78 | } 79 | 80 | @override 81 | Future dispose() async { 82 | _sh.dispose(); 83 | await _limitController.close(); 84 | await _documentsController.drain(); 85 | await _documentsController.close(); 86 | await _hasMoreController.close(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/src/collection_ref.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:firestore_ref/src/utils.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:json_converter_helper/json_converter_helper.dart'; 5 | import 'package:meta/meta.dart'; 6 | 7 | import 'collection_paging_controller.dart'; 8 | import 'document_list.dart'; 9 | 10 | typedef QueryBuilder = Query Function(Query collectionRef); 11 | typedef DocumentDecoder< 12 | E, 13 | D extends Document, 14 | DocRef extends DocumentRef 15 | > = D Function(DocumentSnapshot snapshot, DocRef docRef); 16 | typedef DocRefCreator< 17 | E, 18 | D extends Document, 19 | DocRef extends DocumentRef 20 | > = DocRef Function(DocumentReference ref); 21 | 22 | @immutable 23 | abstract class QueryRef< 24 | E, 25 | D extends Document, 26 | DocRef extends DocumentRef 27 | > { 28 | const QueryRef(this.query); 29 | 30 | final Query query; 31 | 32 | D decode(DocumentSnapshot snapshot, DocRef docRef); 33 | 34 | DocRef docRef(DocumentReference ref); 35 | 36 | JsonMap encode(E data); 37 | 38 | Stream> snapshots([QueryBuilder? queryBuilder]) { 39 | return (queryBuilder ?? (r) => r)(query).snapshots(); 40 | } 41 | 42 | Stream> documents([QueryBuilder? queryBuilder]) { 43 | return documentListResult(queryBuilder).map((r) => r.list); 44 | } 45 | 46 | Stream> documentMap([QueryBuilder? queryBuilder]) { 47 | return documentListResult(queryBuilder).map((r) => r.map); 48 | } 49 | 50 | Stream> documentListResult([ 51 | QueryBuilder? queryBuilder, 52 | ]) { 53 | final documentList = DocumentList( 54 | docRefCreator: docRef, 55 | decoder: decode, 56 | ); 57 | return snapshots(queryBuilder).map(documentList.applyingSnapshot); 58 | } 59 | 60 | Future> getSnapshots([ 61 | QueryBuilder? queryBuilder, 62 | GetOptions? options, 63 | ]) async { 64 | final result = await (queryBuilder ?? (r) => r)(query).get(options); 65 | if (firestoreOperationCounter.enabled) { 66 | final count = result.docs.length; 67 | firestoreOperationCounter.recordRead( 68 | isFromCache: result.metadata.isFromCache, 69 | count: count, 70 | ); 71 | } 72 | return result; 73 | } 74 | 75 | Future> getDocuments([QueryBuilder? queryBuilder]) async { 76 | final snapshots = await getSnapshots(queryBuilder); 77 | return snapshots.docs 78 | .map((snap) => decode(snap, docRef(snap.reference))) 79 | .toList(); 80 | } 81 | 82 | CollectionPagingController pagingController({ 83 | QueryBuilder? queryBuilder, 84 | int initialSize = 10, 85 | int defaultPagingSize = 10, 86 | }) { 87 | return CollectionPagingController( 88 | queryRef: this, 89 | queryBuilder: queryBuilder, 90 | initialSize: initialSize, 91 | defaultPagingSize: defaultPagingSize, 92 | ); 93 | } 94 | 95 | /// Delete all documents 96 | /// 97 | /// Default value of [batchSize] is 500, which is max limit of Batch Write. 98 | /// Return value is deleted document references. 99 | Future> deleteAllDocuments({int batchSize = 500}) { 100 | return _deleteQueryBatch( 101 | query: query.orderBy(FieldPath.documentId).limit(batchSize), 102 | batchSize: batchSize, 103 | deletedRefs: [], 104 | ); 105 | } 106 | 107 | Future> _deleteQueryBatch({ 108 | required Query query, 109 | required int batchSize, 110 | required List deletedRefs, 111 | }) async { 112 | final snapshots = await query.get(); 113 | final docs = snapshots.docs; 114 | if (docs.isEmpty) { 115 | return deletedRefs; 116 | } 117 | 118 | if (firestoreOperationCounter.enabled) { 119 | firestoreOperationCounter.recordDelete(count: docs.length); 120 | } 121 | 122 | await runBatchWrite((batch) { 123 | for (final doc in docs) { 124 | batch.delete(doc.reference); 125 | } 126 | return Future.value(); 127 | }); 128 | 129 | logger.fine('deleted count: ${docs.length}'); 130 | 131 | return _deleteQueryBatch( 132 | query: query, 133 | batchSize: batchSize, 134 | deletedRefs: [...deletedRefs, ...docs.map((d) => d.reference)], 135 | ); 136 | } 137 | 138 | @override 139 | bool operator ==(Object other) => 140 | identical(this, other) || 141 | other is QueryRef && 142 | runtimeType == other.runtimeType && 143 | query == other.query; 144 | 145 | @override 146 | int get hashCode => query.hashCode; 147 | } 148 | 149 | @immutable 150 | abstract class CollectionGroupRef< 151 | E, 152 | D extends Document, 153 | DocRef extends DocumentRef 154 | > 155 | extends QueryRef { 156 | CollectionGroupRef(String collectionPath) 157 | : super(FirebaseFirestore.instance.collectionGroup(collectionPath)); 158 | } 159 | 160 | @immutable 161 | abstract class CollectionRef< 162 | E, 163 | D extends Document, 164 | DocRef extends DocumentRef 165 | > 166 | extends QueryRef { 167 | const CollectionRef(this.ref) : super(ref); 168 | 169 | final CollectionReference ref; 170 | 171 | DocRef docRefWithId([String? id]) { 172 | return docRef(ref.doc(id)); 173 | } 174 | 175 | Future add(E entity) async { 176 | final rawRef = await ref.add(encode(entity)); 177 | return docRef(rawRef); 178 | } 179 | } 180 | 181 | class DocumentListResult< 182 | E, 183 | D extends Document, 184 | DocRef extends DocumentRef 185 | > { 186 | DocumentListResult({required this.list, required this.map}); 187 | DocumentListResult.empty() : this(list: [], map: {}); 188 | 189 | final List list; 190 | final Map map; 191 | 192 | bool get isEmpty => list.isEmpty && map.isEmpty; 193 | } 194 | -------------------------------------------------------------------------------- /lib/src/document.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:meta/meta.dart'; 3 | 4 | @immutable 5 | class Document { 6 | const Document( 7 | this.ref, 8 | this.entity, 9 | ); 10 | 11 | final DocumentRef> ref; 12 | final E? entity; 13 | String get id => ref.ref.id; 14 | 15 | @override 16 | bool operator ==(Object other) => 17 | identical(this, other) || 18 | other is Document && 19 | runtimeType == other.runtimeType && 20 | ref == other.ref && 21 | entity == other.entity; 22 | 23 | @override 24 | int get hashCode => ref.hashCode ^ entity.hashCode; 25 | 26 | @override 27 | String toString() { 28 | return ''' 29 | Document<$E>( 30 | ref: $ref, 31 | entity: $entity 32 | )'''; 33 | } 34 | 35 | Document copyWith(E entity) { 36 | return Document( 37 | ref, 38 | entity ?? this.entity, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/src/document_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:json_converter_helper/json_converter_helper.dart'; 3 | 4 | class DocumentList, DocRef extends DocumentRef> { 5 | DocumentList({ 6 | required this.docRefCreator, 7 | required this.decoder, 8 | }); 9 | 10 | final DocRefCreator docRefCreator; 11 | final DocumentDecoder decoder; 12 | final _documents = []; 13 | final _map = {}; 14 | 15 | DocumentListResult applyingSnapshot( 16 | QuerySnapshot snapshot, 17 | ) { 18 | if (firestoreOperationCounter.enabled) { 19 | firestoreOperationCounter.recordRead( 20 | isFromCache: snapshot.metadata.isFromCache, 21 | count: snapshot.docChanges.length, 22 | ); 23 | } 24 | for (final change in snapshot.docChanges) { 25 | final doc = change.doc; 26 | switch (change.type) { 27 | case DocumentChangeType.added: 28 | final docRef = docRefCreator(doc.reference); 29 | final decoded = decoder( 30 | doc, 31 | docRef, 32 | ); 33 | _documents.insert( 34 | change.newIndex, 35 | decoded, 36 | ); 37 | _map[docRef] = decoded; 38 | case DocumentChangeType.removed: 39 | _documents.removeAt(change.oldIndex); 40 | _map.remove(doc.reference); 41 | case DocumentChangeType.modified: 42 | final oldDoc = _documents.removeAt(change.oldIndex); 43 | // ignore: cast_nullable_to_non_nullable 44 | final docRef = oldDoc.ref as DocRef; 45 | final decoded = decoder( 46 | doc, 47 | docRef, 48 | ); 49 | _documents.insert( 50 | change.newIndex, 51 | decoded, 52 | ); 53 | _map[docRef] = decoded; 54 | } 55 | } 56 | return DocumentListResult( 57 | list: List.unmodifiable(_documents), 58 | map: Map.unmodifiable(_map), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/src/document_ref.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:json_converter_helper/json_converter_helper.dart'; 3 | import 'package:meta/meta.dart'; 4 | 5 | import 'utils.dart'; 6 | 7 | @immutable 8 | class DocumentRef> { 9 | const DocumentRef({ 10 | required this.ref, 11 | required this.collectionRef, 12 | }); 13 | 14 | final QueryRef> collectionRef; 15 | final DocumentReference ref; 16 | String get id => ref.id; 17 | 18 | Stream document() { 19 | return ref.snapshots().map((snapshot) { 20 | if (firestoreOperationCounter.enabled) { 21 | firestoreOperationCounter.recordRead( 22 | isFromCache: snapshot.metadata.isFromCache, 23 | ); 24 | } 25 | if (!snapshot.exists) { 26 | logger.warning('$D not found(id: ${ref.id})'); 27 | return null; 28 | } 29 | return collectionRef.decode( 30 | snapshot, 31 | this, 32 | ); 33 | }); 34 | } 35 | 36 | /// [options] doesn't work with [transaction] 37 | Future get({ 38 | GetOptions? options, 39 | Transaction? transaction, 40 | }) async { 41 | final snapshot = 42 | await (transaction == null ? ref.get(options) : transaction.get(ref)); 43 | if (firestoreOperationCounter.enabled) { 44 | firestoreOperationCounter.recordRead( 45 | isFromCache: snapshot.metadata.isFromCache, 46 | ); 47 | } 48 | if (!snapshot.exists) { 49 | logger.warning('$D not found(id: ${ref.id})'); 50 | return Future.value(); 51 | } 52 | return collectionRef.decode( 53 | snapshot, 54 | this, 55 | ); 56 | } 57 | 58 | /// すでにあるデータに対して 59 | /// マージと似ているがそのキーの配下のものは置き換わる 60 | Future update( 61 | E entity, { 62 | WriteBatch? batch, 63 | Transaction? transaction, 64 | }) { 65 | return updateData( 66 | collectionRef.encode(entity), 67 | batch: batch, 68 | transaction: transaction, 69 | ); 70 | } 71 | 72 | /// すでにあるデータに対して 73 | /// マージと似ているがそのキーの配下のものは置き換わる 74 | Future updateData( 75 | JsonMap data, { 76 | WriteBatch? batch, 77 | Transaction? transaction, 78 | }) { 79 | assert(batch == null || transaction == null); 80 | if (firestoreOperationCounter.enabled) { 81 | firestoreOperationCounter.recordWrite(); 82 | } 83 | if (batch == null && transaction == null) { 84 | return ref.update(data); 85 | } 86 | if (batch != null) { 87 | batch.update(ref, data); 88 | return Future.value(); 89 | } 90 | if (transaction != null) { 91 | transaction.update(ref, data); 92 | return Future.value(); 93 | } 94 | assert(false); 95 | return Future.value(); 96 | } 97 | 98 | /// 全置き換え 99 | Future set( 100 | E entity, { 101 | WriteBatch? batch, 102 | Transaction? transaction, 103 | }) { 104 | return setData( 105 | collectionRef.encode(entity), 106 | batch: batch, 107 | transaction: transaction, 108 | ); 109 | } 110 | 111 | /// 全置き換え 112 | Future setData( 113 | JsonMap data, { 114 | WriteBatch? batch, 115 | Transaction? transaction, 116 | }) { 117 | assert(batch == null || transaction == null); 118 | if (firestoreOperationCounter.enabled) { 119 | firestoreOperationCounter.recordWrite(); 120 | } 121 | if (batch == null && transaction == null) { 122 | return ref.set(data); 123 | } 124 | if (batch != null) { 125 | batch.set(ref, data); 126 | return Future.value(); 127 | } 128 | if (transaction != null) { 129 | transaction.set(ref, data); 130 | return Future.value(); 131 | } 132 | assert(false); 133 | return Future.value(); 134 | } 135 | 136 | /// マージ 137 | Future merge( 138 | E entity, { 139 | WriteBatch? batch, 140 | Transaction? transaction, 141 | }) { 142 | return mergeData( 143 | collectionRef.encode(entity), 144 | batch: batch, 145 | transaction: transaction, 146 | ); 147 | } 148 | 149 | /// マージ 150 | Future mergeData( 151 | JsonMap data, { 152 | WriteBatch? batch, 153 | Transaction? transaction, 154 | }) { 155 | assert(batch == null || transaction == null); 156 | if (firestoreOperationCounter.enabled) { 157 | firestoreOperationCounter.recordWrite(); 158 | } 159 | if (batch == null && transaction == null) { 160 | return ref.set(data, SetOptions(merge: true)); 161 | } 162 | if (batch != null) { 163 | batch.set(ref, data, SetOptions(merge: true)); 164 | return Future.value(); 165 | } 166 | if (transaction != null) { 167 | transaction.set(ref, data, SetOptions(merge: true)); 168 | return Future.value(); 169 | } 170 | assert(false); 171 | return Future.value(); 172 | } 173 | 174 | Future delete({ 175 | WriteBatch? batch, 176 | Transaction? transaction, 177 | }) { 178 | assert(batch == null || transaction == null); 179 | if (firestoreOperationCounter.enabled) { 180 | firestoreOperationCounter.recordDelete(); 181 | } 182 | if (batch == null && transaction == null) { 183 | return ref.delete(); 184 | } 185 | if (batch != null) { 186 | batch.delete(ref); 187 | return Future.value(); 188 | } 189 | if (transaction != null) { 190 | transaction.delete(ref); 191 | return Future.value(); 192 | } 193 | assert(false); 194 | return Future.value(); 195 | } 196 | 197 | @override 198 | bool operator ==(Object other) => 199 | identical(this, other) || 200 | other is DocumentRef && 201 | runtimeType == other.runtimeType && 202 | ref == other.ref; 203 | 204 | @override 205 | int get hashCode => ref.hashCode; 206 | } 207 | -------------------------------------------------------------------------------- /lib/src/firestore_operation_counter.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/src/utils.dart'; 2 | import 'package:simple_logger/simple_logger.dart'; 3 | 4 | final firestoreOperationCounter = _FirestoreOperationCounter(); 5 | 6 | class _FirestoreOperationCounter { 7 | // ignore: omit_obvious_property_types 8 | bool enabled = false; 9 | Level traceLogLevel = Level.FINE; 10 | 11 | var _read = 0; 12 | var _readFromCache = 0; 13 | var _write = 0; 14 | var _delete = 0; 15 | 16 | int get read => _read; 17 | int get readFromCache => _readFromCache; 18 | int get readTotal => _read + _readFromCache; 19 | int get write => _write; 20 | int get delete => _delete; 21 | double get readPriceUsCentralInUSD => _read * 0.06 / 100000; 22 | double get writePriceUsCentralInUSD => _write * 0.18 / 100000; 23 | double get deletePriceUsCentralInUSD => _delete * 0.02 / 100000; 24 | double get totalPriceUsCentralInUSD => 25 | readPriceUsCentralInUSD + 26 | writePriceUsCentralInUSD + 27 | deletePriceUsCentralInUSD; 28 | double get cacheHitRatio => readTotal == 0 ? 0 : readFromCache / readTotal; 29 | 30 | void recordRead({required bool isFromCache, int count = 1}) { 31 | logger.log( 32 | traceLogLevel, 33 | 'recordRead(isFromCache: $isFromCache, count: $count)', 34 | ); 35 | isFromCache ? _readFromCache += count : _read += count; 36 | logger.log(traceLogLevel, this); 37 | } 38 | 39 | void recordWrite({int count = 1}) { 40 | logger.log(traceLogLevel, 'recordWrite(count: $count)'); 41 | _write += count; 42 | logger.log(traceLogLevel, this); 43 | } 44 | 45 | void recordDelete({int count = 1}) { 46 | logger.log(traceLogLevel, 'recordDelete(count: $count)'); 47 | _delete += count; 48 | logger.log(traceLogLevel, this); 49 | } 50 | 51 | @override 52 | String toString() { 53 | return ''' 54 | AccessCounter{ 55 | read: $read (\$${readPriceUsCentralInUSD.toStringAsPrecision(3)}) 56 | readFromCache: $readFromCache (cache hit: ${(cacheHitRatio * 100).toStringAsPrecision(3)} %) 57 | write: $write (\$${writePriceUsCentralInUSD.toStringAsPrecision(3)}) 58 | delete: $delete (\$${deletePriceUsCentralInUSD.toStringAsPrecision(3)}) 59 | totalPrice(UsCentral): \$${totalPriceUsCentralInUSD.toStringAsPrecision(3)} 60 | } 61 | '''; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/src/functions.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:json_converter_helper/json_converter_helper.dart'; 3 | import 'package:quiver/iterables.dart'; 4 | 5 | Future runBatchWrite(Future Function(WriteBatch batch) f) async { 6 | final batch = FirebaseFirestore.instance.batch(); 7 | final result = await f(batch); 8 | await batch.commit(); 9 | return result; 10 | } 11 | 12 | Future deleteDocuments({ 13 | required List references, 14 | int batchSize = 500, 15 | }) { 16 | return Future.wait( 17 | partition(references, batchSize).map( 18 | (chunked) => runBatchWrite((batch) { 19 | chunked.forEach(batch.delete); 20 | return Future.value(); 21 | }), 22 | ), 23 | ); 24 | } 25 | 26 | JsonMap? parseJson( 27 | JsonMap json, { 28 | required String key, 29 | }) { 30 | final value = json[key] as Map?; 31 | return value == null ? null : Map.from(value); 32 | } 33 | 34 | T? parse( 35 | JsonMap json, { 36 | required String key, 37 | required T Function(JsonMap) fromJson, 38 | }) { 39 | final parsedJson = parseJson(json, key: key); 40 | return parsedJson == null ? null : fromJson(parsedJson); 41 | } 42 | -------------------------------------------------------------------------------- /lib/src/timestamp.dart: -------------------------------------------------------------------------------- 1 | import 'package:firestore_ref/firestore_ref.dart'; 2 | import 'package:json_converter_helper/json_converter_helper.dart'; 3 | 4 | class TimestampField { 5 | static const createdAt = 'createdAt'; 6 | static const updatedAt = 'updatedAt'; 7 | } 8 | 9 | @Deprecated('Use UnionTimestamp instead.') 10 | JsonMap replacingTimestamp({ 11 | required JsonMap json, 12 | }) => 13 | { 14 | ...json, 15 | if (json[TimestampField.createdAt] == null) 16 | TimestampField.createdAt: FieldValue.serverTimestamp(), 17 | TimestampField.updatedAt: FieldValue.serverTimestamp(), 18 | }; 19 | 20 | DateTime? parseTimestamp({ 21 | required JsonMap json, 22 | required String key, 23 | }) { 24 | return (json[key] as Timestamp?)?.toDate(); 25 | } 26 | -------------------------------------------------------------------------------- /lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:simple_logger/simple_logger.dart'; 2 | 3 | SimpleLogger get logger => SimpleLogger(); 4 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: firestore_ref 2 | description: Firestore reference/document typed access helpers. You can write organized safe code by this. 3 | version: 0.15.0 4 | homepage: https://github.com/mono0926/flutter_firestore_ref 5 | environment: 6 | sdk: ^3.8.0 7 | dependencies: 8 | cloud_firestore: ^5.0.0 9 | disposable_provider: ^2.3.0 10 | firebase_core: ^3.0.0 11 | flutter: 12 | sdk: flutter 13 | json_annotation: ^4.6.0 14 | json_converter_helper: '>=0.1.1 <2.0.0' 15 | meta: ^1.3.0 16 | quiver: ^3.0.0 17 | rxdart: '>=0.27.0 <1.0.0' 18 | simple_logger: ^1.8.0 19 | subscription_holder: ^2.1.0 20 | dev_dependencies: 21 | flutter_test: 22 | sdk: flutter 23 | pedantic_mono: 24 | false_secrets: 25 | - google-services.json 26 | - GoogleService-Info.plist 27 | - example/web/index.html 28 | - example/lib/firebase_options.dart 29 | -------------------------------------------------------------------------------- /test/firestore_ref_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | void main() { 4 | test('', () {}); 5 | } 6 | --------------------------------------------------------------------------------