├── .gitattributes ├── .gitignore ├── .metadata ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle.kts │ │ └── 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 │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle.kts ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ ├── app.dart │ ├── home.dart │ └── main.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ └── runner │ │ ├── CMakeLists.txt │ │ ├── main.cc │ │ ├── my_application.cc │ │ └── my_application.h ├── 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 │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── 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 ├── sqlite_fs.dart └── src │ ├── database │ ├── db.dart │ └── types │ │ ├── db.dart │ │ ├── schema.dart │ │ └── selectable.dart │ └── file_system │ ├── fs.dart │ ├── io.dart │ ├── types │ ├── common.dart │ ├── directory.dart │ ├── file.dart │ ├── file_io_sink.dart │ ├── file_mode.dart │ ├── file_stat.dart │ ├── file_system.dart │ ├── file_system_entity.dart │ ├── link.dart │ └── random_access_file.dart │ └── utils.dart ├── pubspec.lock ├── pubspec.yaml └── test ├── example.dart └── fs_test.dart /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .pub-cache/ 33 | .pub/ 34 | /build/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /.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: "09de023485e95e6d1225c2baa44b8feb85e0d45f" 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: 09de023485e95e6d1225c2baa44b8feb85e0d45f 17 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 18 | - platform: android 19 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 20 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 21 | - platform: ios 22 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 23 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 24 | - platform: linux 25 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 26 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 27 | - platform: macos 28 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 29 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 30 | - platform: web 31 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 32 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 33 | - platform: windows 34 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 35 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "fossil.ignoreMissingFossilWarning": true 3 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sqlite_fs 2 | 3 | Using the package `sqlite3` to create a file system from the package `file` in Dart. 4 | 5 | ```dart 6 | import 'package:file/file.dart'; 7 | import 'package:sqlite3/sqlite3.dart'; 8 | import 'package:sqlite_fs/sqlite_fs.dart'; 9 | 10 | void main() { 11 | final fs = SqliteFileSystem.fromDb(sqlite3.openInMemory()); 12 | 13 | final dir = fs.directory('temp'); 14 | if (dir.existsSync()) { 15 | dir.deleteSync(recursive: true); 16 | } 17 | dir.createSync(recursive: true); 18 | 19 | _addFile(fs, dir, 'file1.txt'); 20 | _addFile(fs, dir, 'file2.txt'); 21 | 22 | _addDirectory(fs, dir, 'dir1'); 23 | _addDirectory(fs, dir, 'dir2'); 24 | 25 | final files = dir.listSync(); 26 | final paths = files.map((file) => file.path).toList(); 27 | print('paths: $paths'); 28 | 29 | dir.deleteSync(recursive: true); 30 | fs.db.close(); 31 | } 32 | 33 | File _addFile(FileSystem fs, Directory dir, String path) { 34 | final file = fs.file(fs.path.join(dir.path, path)); 35 | file.writeAsStringSync('Hello, world!'); 36 | return file; 37 | } 38 | 39 | Directory _addDirectory(FileSystem fs, Directory dir, String path) { 40 | final directory = fs.directory(fs.path.join(dir.path, path)); 41 | directory.createSync(recursive: true); 42 | return directory; 43 | } 44 | ``` -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .pub-cache/ 33 | .pub/ 34 | /build/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /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: "09de023485e95e6d1225c2baa44b8feb85e0d45f" 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: 09de023485e95e6d1225c2baa44b8feb85e0d45f 17 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 18 | - platform: android 19 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 20 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 21 | - platform: ios 22 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 23 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 24 | - platform: linux 25 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 26 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 27 | - platform: macos 28 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 29 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 30 | - platform: web 31 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 32 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 33 | - platform: windows 34 | create_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 35 | base_revision: 09de023485e95e6d1225c2baa44b8feb85e0d45f 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 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://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | .cxx/ 9 | 10 | # Remember to never publicly share your keystore. 11 | # See https://flutter.dev/to/reference-keystore 12 | key.properties 13 | **/*.keystore 14 | **/*.jks 15 | -------------------------------------------------------------------------------- /example/android/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id("dev.flutter.flutter-gradle-plugin") 6 | } 7 | 8 | android { 9 | namespace = "com.example.example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_11 15 | targetCompatibility = JavaVersion.VERSION_11 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_11.toString() 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.example.example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.getByName("debug") 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() 9 | rootProject.layout.buildDirectory.value(newBuildDir) 10 | 11 | subprojects { 12 | val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) 13 | project.layout.buildDirectory.value(newSubprojectBuildDir) 14 | } 15 | subprojects { 16 | project.evaluationDependsOn(":app") 17 | } 18 | 19 | tasks.register("clean") { 20 | delete(rootProject.layout.buildDirectory) 21 | } 22 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -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-8.10.2-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val flutterSdkPath = run { 3 | val properties = java.util.Properties() 4 | file("local.properties").inputStream().use { properties.load(it) } 5 | val flutterSdkPath = properties.getProperty("flutter.sdk") 6 | require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } 7 | 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 "8.7.0" apply false 22 | id("org.jetbrains.kotlin.android") version "1.8.22" apply false 23 | } 24 | 25 | include(":app") 26 | -------------------------------------------------------------------------------- /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 | 12.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, '12.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 | 33 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_ios_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /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 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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 Flutter 2 | import UIKit 3 | 4 | @main 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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/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 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:sqlite3/common.dart'; 3 | import 'package:sqlite_fs/sqlite_fs.dart'; 4 | 5 | import 'home.dart'; 6 | 7 | class App extends StatelessWidget { 8 | App({ 9 | super.key, 10 | required this.fs, 11 | required this.db, 12 | this.seedColor = Colors.blue, 13 | }); 14 | 15 | final SqliteFileSystem fs; 16 | final CommonDatabase db; 17 | final Color seedColor; 18 | 19 | late final lightColorScheme = ColorScheme.fromSeed( 20 | seedColor: seedColor, 21 | brightness: Brightness.light, 22 | ); 23 | late final darkColorScheme = ColorScheme.fromSeed( 24 | seedColor: seedColor, 25 | brightness: Brightness.dark, 26 | ); 27 | late final lightTheme = ThemeData.light().copyWith( 28 | colorScheme: lightColorScheme, 29 | ); 30 | late final darkTheme = ThemeData.dark().copyWith( 31 | colorScheme: darkColorScheme, 32 | ); 33 | 34 | @override 35 | Widget build(BuildContext context) { 36 | return MaterialApp( 37 | debugShowCheckedModeBanner: false, 38 | home: Home(fs: fs, db: db), 39 | theme: lightTheme, 40 | darkTheme: darkTheme, 41 | themeMode: ThemeMode.system, 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /example/lib/home.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:signals/signals_flutter.dart'; 5 | import 'package:sqlite3/common.dart'; 6 | import 'package:sqlite_fs/sqlite_fs.dart'; 7 | 8 | class Home extends StatefulWidget { 9 | const Home({super.key, required this.fs, required this.db}); 10 | 11 | final SqliteFileSystem fs; 12 | final CommonDatabase db; 13 | 14 | @override 15 | State createState() => _HomeState(); 16 | } 17 | 18 | class _HomeState extends State with SignalsMixin { 19 | late final fs = widget.fs; 20 | late final db = widget.db; 21 | 22 | StreamSubscription? _watcher; 23 | late final selected = bindSignal(trackedSignal(null)); 24 | 25 | late final dir = createSignal(widget.fs.directory('/')); 26 | late final files = createSignal>([]); 27 | 28 | void _refresh() { 29 | final target = selected() ?? widget.fs.directory('/'); 30 | if (target is Directory) { 31 | files.value = target.listSync(followLinks: false).toList(); 32 | } else if (target is File) { 33 | files.value = target.parent.listSync(followLinks: false).toList(); 34 | } else if (target is Link) { 35 | files.value = target.parent.listSync(followLinks: false).toList(); 36 | } 37 | } 38 | 39 | @override 40 | void initState() { 41 | super.initState(); 42 | createEffect(() { 43 | _refresh(); 44 | _watcher?.cancel(); 45 | _watcher = dir().watch().listen((event) { 46 | _refresh(); 47 | }); 48 | }); 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | final size = MediaQuery.of(context).size; 54 | final crossAxisCount = size.width ~/ 100; 55 | final current = selected() ?? widget.fs.directory('/'); 56 | return Scaffold( 57 | appBar: AppBar( 58 | title: Text('SQLite File System'), 59 | actions: [IconButton(icon: Icon(Icons.refresh), onPressed: _refresh)], 60 | ), 61 | body: GridView.count( 62 | crossAxisCount: crossAxisCount, 63 | children: [ 64 | FileSystemEntityWidget( 65 | entity: current.parent, 66 | onTap: selected.set, 67 | label: '..', 68 | selected: '', 69 | ), 70 | for (final file in files()) 71 | FileSystemEntityWidget( 72 | entity: file, 73 | onTap: selected.set, 74 | selected: current.path, 75 | ), 76 | ], 77 | ), 78 | persistentFooterButtons: [ 79 | if (current is Directory) 80 | TextButton.icon( 81 | label: Text('Add File'), 82 | icon: Icon(Icons.add), 83 | onPressed: () { 84 | int count = 0; 85 | 86 | String name() { 87 | return '$count-file.txt'; 88 | } 89 | 90 | while (fs.file(fs.path.join(current.path, name())).existsSync()) { 91 | count++; 92 | } 93 | final file = fs.file( 94 | fs.path.normalize(fs.path.join(current.path, name())), 95 | ); 96 | file.createSync(recursive: true); 97 | file.writeAsStringSync('Hello, World!'); 98 | _refresh(); 99 | }, 100 | ), 101 | TextButton.icon( 102 | label: Text('Add Link'), 103 | icon: Icon(Icons.add), 104 | onPressed: () { 105 | int count = 0; 106 | 107 | String name() { 108 | return 'link-$count-${fs.path.basename(current.path)}'; 109 | } 110 | 111 | while (fs 112 | .link(fs.path.join(current.parent.path, name())) 113 | .existsSync()) { 114 | count++; 115 | } 116 | final link = fs.link( 117 | fs.path.normalize(fs.path.join(current.parent.path, name())), 118 | ); 119 | link.createSync(current.path, recursive: true); 120 | _refresh(); 121 | }, 122 | ), 123 | if (current is Directory) 124 | TextButton.icon( 125 | label: Text('Add Directory'), 126 | icon: Icon(Icons.add), 127 | onPressed: () { 128 | int count = 0; 129 | 130 | String name() { 131 | return 'dir-$count'; 132 | } 133 | 134 | while (fs 135 | .directory(fs.path.join(current.path, name())) 136 | .existsSync()) { 137 | count++; 138 | } 139 | 140 | final dir = fs.directory( 141 | fs.path.normalize(fs.path.join(current.path, name())), 142 | ); 143 | dir.createSync(recursive: true); 144 | _refresh(); 145 | }, 146 | ), 147 | ], 148 | ); 149 | } 150 | } 151 | 152 | class FileSystemEntityWidget extends StatelessWidget { 153 | const FileSystemEntityWidget({ 154 | super.key, 155 | required this.entity, 156 | required this.onTap, 157 | required this.selected, 158 | this.label, 159 | }); 160 | 161 | final FileSystemEntity entity; 162 | final ValueChanged onTap; 163 | final String? label; 164 | final String selected; 165 | 166 | @override 167 | Widget build(BuildContext context) { 168 | final isDir = entity is Directory; 169 | final isLink = entity is Link; 170 | final isFile = entity is File; 171 | final isSelected = entity.path == selected; 172 | final colors = Theme.of(context).colorScheme; 173 | final bgColor = isDir ? colors.secondary : colors.primary; 174 | // final fgColor = isDir ? colors.onSecondary : colors.onPrimary; 175 | return Container( 176 | decoration: 177 | isSelected 178 | ? BoxDecoration( 179 | border: Border.all(color: colors.primary, width: 1), 180 | borderRadius: BorderRadius.circular(8), 181 | ) 182 | : null, 183 | child: Column( 184 | mainAxisAlignment: MainAxisAlignment.center, 185 | crossAxisAlignment: CrossAxisAlignment.center, 186 | children: [ 187 | InkWell( 188 | onTap: () => onTap(isSelected ? null : entity), 189 | child: Center( 190 | child: Icon( 191 | isDir 192 | ? isLink 193 | ? Icons.folder_outlined 194 | : Icons.folder 195 | : isFile 196 | ? Icons.file_copy 197 | : isLink 198 | ? Icons.file_copy_outlined 199 | : Icons.error, 200 | color: bgColor, 201 | size: 48, 202 | ), 203 | ), 204 | ), 205 | const SizedBox(height: 4), 206 | Text( 207 | label ?? entity.path.split('/').last, 208 | style: TextStyle(color: colors.onSurface, fontSize: 8), 209 | ), 210 | ], 211 | ), 212 | ); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:sqlite3/sqlite3.dart'; 3 | import 'package:sqlite_fs/sqlite_fs.dart'; 4 | 5 | import 'app.dart'; 6 | 7 | void main() { 8 | final db = sqlite3.openInMemory(); 9 | final fs = SqliteFileSystem.fromDb(db); 10 | runApp(App(fs: fs, db: db)); 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.13) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.example") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | # Application build; see runner/CMakeLists.txt. 58 | add_subdirectory("runner") 59 | 60 | # Run the Flutter tool portions of the build. This must not be removed. 61 | add_dependencies(${BINARY_NAME} flutter_assemble) 62 | 63 | # Only the install-generated bundle's copy of the executable will launch 64 | # correctly, since the resources must in the right relative locations. To avoid 65 | # people trying to run the unbundled copy, put it in a subdirectory instead of 66 | # the default top-level location. 67 | set_target_properties(${BINARY_NAME} 68 | PROPERTIES 69 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 70 | ) 71 | 72 | 73 | # Generated plugin build rules, which manage building the plugins and adding 74 | # them to the application. 75 | include(flutter/generated_plugins.cmake) 76 | 77 | 78 | # === Installation === 79 | # By default, "installing" just makes a relocatable bundle in the build 80 | # directory. 81 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 82 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 83 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 84 | endif() 85 | 86 | # Start with a clean build bundle directory every time. 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 89 | " COMPONENT Runtime) 90 | 91 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 92 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 93 | 94 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 95 | COMPONENT Runtime) 96 | 97 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 98 | COMPONENT Runtime) 99 | 100 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 101 | COMPONENT Runtime) 102 | 103 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 104 | install(FILES "${bundled_library}" 105 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 106 | COMPONENT Runtime) 107 | endforeach(bundled_library) 108 | 109 | # Copy the native assets provided by the build.dart from all packages. 110 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 111 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 112 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 113 | COMPONENT Runtime) 114 | 115 | # Fully re-copy the assets directory on each build to avoid having stale files 116 | # from a previous install. 117 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 118 | install(CODE " 119 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 120 | " COMPONENT Runtime) 121 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 122 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 123 | 124 | # Install the AOT library on non-Debug builds only. 125 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 126 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 127 | COMPONENT Runtime) 128 | endif() 129 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); 14 | sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | sqlite3_flutter_libs 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/linux/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} 10 | "main.cc" 11 | "my_application.cc" 12 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 13 | ) 14 | 15 | # Apply the standard set of build settings. This can be removed for applications 16 | # that need different build settings. 17 | apply_standard_settings(${BINARY_NAME}) 18 | 19 | # Add preprocessor definitions for the application ID. 20 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 21 | 22 | # Add dependency libraries. Add any application-specific dependencies here. 23 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 24 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 25 | 26 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 27 | -------------------------------------------------------------------------------- /example/linux/runner/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/runner/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GApplication::startup. 85 | static void my_application_startup(GApplication* application) { 86 | //MyApplication* self = MY_APPLICATION(object); 87 | 88 | // Perform any actions required at application startup. 89 | 90 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application); 91 | } 92 | 93 | // Implements GApplication::shutdown. 94 | static void my_application_shutdown(GApplication* application) { 95 | //MyApplication* self = MY_APPLICATION(object); 96 | 97 | // Perform any actions required at application shutdown. 98 | 99 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); 100 | } 101 | 102 | // Implements GObject::dispose. 103 | static void my_application_dispose(GObject* object) { 104 | MyApplication* self = MY_APPLICATION(object); 105 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 106 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 107 | } 108 | 109 | static void my_application_class_init(MyApplicationClass* klass) { 110 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 111 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 112 | G_APPLICATION_CLASS(klass)->startup = my_application_startup; 113 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; 114 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 115 | } 116 | 117 | static void my_application_init(MyApplication* self) {} 118 | 119 | MyApplication* my_application_new() { 120 | // Set the program name to the application ID, which helps various systems 121 | // like GTK and desktop environments map this running application to its 122 | // corresponding .desktop file. This ensures better integration by allowing 123 | // the application to be recognized beyond its binary name. 124 | g_set_prgname(APPLICATION_ID); 125 | 126 | return MY_APPLICATION(g_object_new(my_application_get_type(), 127 | "application-id", APPLICATION_ID, 128 | "flags", G_APPLICATION_NON_UNIQUE, 129 | nullptr)); 130 | } 131 | -------------------------------------------------------------------------------- /example/linux/runner/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /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 path_provider_foundation 9 | import sqlite3_flutter_libs 10 | 11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 12 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 13 | Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin")) 14 | } 15 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 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 | 32 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 33 | target 'RunnerTests' do 34 | inherit! :search_paths 35 | end 36 | end 37 | 38 | post_install do |installer| 39 | installer.pods_project.targets.each do |target| 40 | flutter_additional_macos_build_settings(target) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | - path_provider_foundation (0.0.1): 4 | - Flutter 5 | - FlutterMacOS 6 | - sqlite3 (3.49.1): 7 | - sqlite3/common (= 3.49.1) 8 | - sqlite3/common (3.49.1) 9 | - sqlite3/dbstatvtab (3.49.1): 10 | - sqlite3/common 11 | - sqlite3/fts5 (3.49.1): 12 | - sqlite3/common 13 | - sqlite3/math (3.49.1): 14 | - sqlite3/common 15 | - sqlite3/perf-threadsafe (3.49.1): 16 | - sqlite3/common 17 | - sqlite3/rtree (3.49.1): 18 | - sqlite3/common 19 | - sqlite3_flutter_libs (0.0.1): 20 | - Flutter 21 | - FlutterMacOS 22 | - sqlite3 (~> 3.49.1) 23 | - sqlite3/dbstatvtab 24 | - sqlite3/fts5 25 | - sqlite3/math 26 | - sqlite3/perf-threadsafe 27 | - sqlite3/rtree 28 | 29 | DEPENDENCIES: 30 | - FlutterMacOS (from `Flutter/ephemeral`) 31 | - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) 32 | - sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/darwin`) 33 | 34 | SPEC REPOS: 35 | trunk: 36 | - sqlite3 37 | 38 | EXTERNAL SOURCES: 39 | FlutterMacOS: 40 | :path: Flutter/ephemeral 41 | path_provider_foundation: 42 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin 43 | sqlite3_flutter_libs: 44 | :path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/darwin 45 | 46 | SPEC CHECKSUMS: 47 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 48 | path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 49 | sqlite3: fc1400008a9b3525f5914ed715a5d1af0b8f4983 50 | sqlite3_flutter_libs: f6acaa2172e6bb3e2e70c771661905080e8ebcf2 51 | 52 | PODFILE CHECKSUM: 7eb978b976557c8c1cd717d8185ec483fd090a82 53 | 54 | COCOAPODS: 1.16.2 55 | -------------------------------------------------------------------------------- /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 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /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 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | 10 | override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 11 | return true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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 © 2025 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.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /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() 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/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: "A new Flutter project." 3 | publish_to: 'none' 4 | version: 1.0.0+1 5 | 6 | environment: 7 | sdk: ^3.7.0 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | cupertino_icons: ^1.0.8 13 | sqlite3_flutter_libs: ^0.5.32 14 | sqlite3: ^2.7.5 15 | path_provider: ^2.1.5 16 | file: ^7.0.1 17 | sqlite_fs: 18 | path: .. 19 | signals: ^6.0.2 20 | 21 | dev_dependencies: 22 | flutter_test: 23 | sdk: flutter 24 | flutter_lints: ^5.0.0 25 | 26 | flutter: 27 | uses-material-design: true 28 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /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 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | Sqlite3FlutterLibsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /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 | sqlite3_flutter_libs 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /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 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2025 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 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /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.Create(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/rodydavis/sqlite3_filesystem/bb49f1ccb761e40f66e107edf2ad62e42889830f/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 | -------------------------------------------------------------------------------- /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 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /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 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 17 | #endif 18 | 19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 20 | 21 | /// Registry key for app theme preference. 22 | /// 23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 24 | /// value indicates apps should use light mode. 25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; 28 | 29 | // The number of Win32Window objects that currently exist. 30 | static int g_active_window_count = 0; 31 | 32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 33 | 34 | // Scale helper to convert logical scaler values to physical using passed in 35 | // scale factor 36 | int Scale(int source, double scale_factor) { 37 | return static_cast(source * scale_factor); 38 | } 39 | 40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 41 | // This API is only needed for PerMonitor V1 awareness mode. 42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 43 | HMODULE user32_module = LoadLibraryA("User32.dll"); 44 | if (!user32_module) { 45 | return; 46 | } 47 | auto enable_non_client_dpi_scaling = 48 | reinterpret_cast( 49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 50 | if (enable_non_client_dpi_scaling != nullptr) { 51 | enable_non_client_dpi_scaling(hwnd); 52 | } 53 | FreeLibrary(user32_module); 54 | } 55 | 56 | } // namespace 57 | 58 | // Manages the Win32Window's window class registration. 59 | class WindowClassRegistrar { 60 | public: 61 | ~WindowClassRegistrar() = default; 62 | 63 | // Returns the singleton registrar instance. 64 | static WindowClassRegistrar* GetInstance() { 65 | if (!instance_) { 66 | instance_ = new WindowClassRegistrar(); 67 | } 68 | return instance_; 69 | } 70 | 71 | // Returns the name of the window class, registering the class if it hasn't 72 | // previously been registered. 73 | const wchar_t* GetWindowClass(); 74 | 75 | // Unregisters the window class. Should only be called if there are no 76 | // instances of the window. 77 | void UnregisterWindowClass(); 78 | 79 | private: 80 | WindowClassRegistrar() = default; 81 | 82 | static WindowClassRegistrar* instance_; 83 | 84 | bool class_registered_ = false; 85 | }; 86 | 87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 88 | 89 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 90 | if (!class_registered_) { 91 | WNDCLASS window_class{}; 92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 93 | window_class.lpszClassName = kWindowClassName; 94 | window_class.style = CS_HREDRAW | CS_VREDRAW; 95 | window_class.cbClsExtra = 0; 96 | window_class.cbWndExtra = 0; 97 | window_class.hInstance = GetModuleHandle(nullptr); 98 | window_class.hIcon = 99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 100 | window_class.hbrBackground = 0; 101 | window_class.lpszMenuName = nullptr; 102 | window_class.lpfnWndProc = Win32Window::WndProc; 103 | RegisterClass(&window_class); 104 | class_registered_ = true; 105 | } 106 | return kWindowClassName; 107 | } 108 | 109 | void WindowClassRegistrar::UnregisterWindowClass() { 110 | UnregisterClass(kWindowClassName, nullptr); 111 | class_registered_ = false; 112 | } 113 | 114 | Win32Window::Win32Window() { 115 | ++g_active_window_count; 116 | } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring& title, 124 | const Point& origin, 125 | const Size& size) { 126 | Destroy(); 127 | 128 | const wchar_t* window_class = 129 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 130 | 131 | const POINT target_point = {static_cast(origin.x), 132 | static_cast(origin.y)}; 133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 135 | double scale_factor = dpi / 96.0; 136 | 137 | HWND window = CreateWindow( 138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 141 | nullptr, nullptr, GetModuleHandle(nullptr), this); 142 | 143 | if (!window) { 144 | return false; 145 | } 146 | 147 | UpdateTheme(window); 148 | 149 | return OnCreate(); 150 | } 151 | 152 | bool Win32Window::Show() { 153 | return ShowWindow(window_handle_, SW_SHOWNORMAL); 154 | } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 158 | UINT const message, 159 | WPARAM const wparam, 160 | LPARAM const lparam) noexcept { 161 | if (message == WM_NCCREATE) { 162 | auto window_struct = reinterpret_cast(lparam); 163 | SetWindowLongPtr(window, GWLP_USERDATA, 164 | reinterpret_cast(window_struct->lpCreateParams)); 165 | 166 | auto that = static_cast(window_struct->lpCreateParams); 167 | EnableFullDpiSupportIfAvailable(window); 168 | that->window_handle_ = window; 169 | } else if (Win32Window* that = GetThisFromHandle(window)) { 170 | return that->MessageHandler(window, message, wparam, lparam); 171 | } 172 | 173 | return DefWindowProc(window, message, wparam, lparam); 174 | } 175 | 176 | LRESULT 177 | Win32Window::MessageHandler(HWND hwnd, 178 | UINT const message, 179 | WPARAM const wparam, 180 | LPARAM const lparam) noexcept { 181 | switch (message) { 182 | case WM_DESTROY: 183 | window_handle_ = nullptr; 184 | Destroy(); 185 | if (quit_on_close_) { 186 | PostQuitMessage(0); 187 | } 188 | return 0; 189 | 190 | case WM_DPICHANGED: { 191 | auto newRectSize = reinterpret_cast(lparam); 192 | LONG newWidth = newRectSize->right - newRectSize->left; 193 | LONG newHeight = newRectSize->bottom - newRectSize->top; 194 | 195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 197 | 198 | return 0; 199 | } 200 | case WM_SIZE: { 201 | RECT rect = GetClientArea(); 202 | if (child_content_ != nullptr) { 203 | // Size and position the child window. 204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 205 | rect.bottom - rect.top, TRUE); 206 | } 207 | return 0; 208 | } 209 | 210 | case WM_ACTIVATE: 211 | if (child_content_ != nullptr) { 212 | SetFocus(child_content_); 213 | } 214 | return 0; 215 | 216 | case WM_DWMCOLORIZATIONCOLORCHANGED: 217 | UpdateTheme(hwnd); 218 | return 0; 219 | } 220 | 221 | return DefWindowProc(window_handle_, message, wparam, lparam); 222 | } 223 | 224 | void Win32Window::Destroy() { 225 | OnDestroy(); 226 | 227 | if (window_handle_) { 228 | DestroyWindow(window_handle_); 229 | window_handle_ = nullptr; 230 | } 231 | if (g_active_window_count == 0) { 232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 233 | } 234 | } 235 | 236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 237 | return reinterpret_cast( 238 | GetWindowLongPtr(window, GWLP_USERDATA)); 239 | } 240 | 241 | void Win32Window::SetChildContent(HWND content) { 242 | child_content_ = content; 243 | SetParent(content, window_handle_); 244 | RECT frame = GetClientArea(); 245 | 246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 247 | frame.bottom - frame.top, true); 248 | 249 | SetFocus(child_content_); 250 | } 251 | 252 | RECT Win32Window::GetClientArea() { 253 | RECT frame; 254 | GetClientRect(window_handle_, &frame); 255 | return frame; 256 | } 257 | 258 | HWND Win32Window::GetHandle() { 259 | return window_handle_; 260 | } 261 | 262 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 263 | quit_on_close_ = quit_on_close; 264 | } 265 | 266 | bool Win32Window::OnCreate() { 267 | // No-op; provided for subclasses. 268 | return true; 269 | } 270 | 271 | void Win32Window::OnDestroy() { 272 | // No-op; provided for subclasses. 273 | } 274 | 275 | void Win32Window::UpdateTheme(HWND const window) { 276 | DWORD light_mode; 277 | DWORD light_mode_size = sizeof(light_mode); 278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 279 | kGetPreferredBrightnessRegValue, 280 | RRF_RT_REG_DWORD, nullptr, &light_mode, 281 | &light_mode_size); 282 | 283 | if (result == ERROR_SUCCESS) { 284 | BOOL enable_dark_mode = light_mode == 0; 285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 286 | &enable_dark_mode, sizeof(enable_dark_mode)); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /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 a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /lib/sqlite_fs.dart: -------------------------------------------------------------------------------- 1 | export 'src/file_system/fs.dart'; 2 | export 'src/file_system/io.dart'; 3 | export 'src/database/db.dart'; 4 | -------------------------------------------------------------------------------- /lib/src/database/db.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:sqlite3/common.dart'; 4 | 5 | part 'types/db.dart'; 6 | part 'types/schema.dart'; 7 | part 'types/selectable.dart'; 8 | -------------------------------------------------------------------------------- /lib/src/database/types/db.dart: -------------------------------------------------------------------------------- 1 | part of '../db.dart'; 2 | 3 | class DB { 4 | final CommonDatabase db; 5 | static bool autoMigrate = true; 6 | DB(this.db) { 7 | if (autoMigrate) migrate(); 8 | } 9 | 10 | void migrate([bool upgrade = true]) { 11 | final version = db.userVersion; 12 | if (_schema.containsKey(version)) { 13 | var (up, down) = _schema[version]!; 14 | if (upgrade) { 15 | db.execute(up); 16 | } else { 17 | db.execute(down); 18 | } 19 | db.userVersion = upgrade ? version + 1 : version - 1; 20 | } 21 | } 22 | 23 | Selectable select(String sql, [List args = const []]) { 24 | return Selectable(db, sql, args, (row) => row); 25 | } 26 | 27 | List files(String sql, [List args = const []]) { 28 | return select(sql, args).map((row) => row as DatabaseFile).getAll(); 29 | } 30 | 31 | DatabaseFile? file(String path) { 32 | return select('SELECT * FROM files WHERE path = ?', [ 33 | path, 34 | ]).map((row) => row as DatabaseFile).getSingleOrNull(); 35 | } 36 | 37 | void deleteFile(String path) { 38 | db.execute('DELETE FROM files WHERE path = ?', [path]); 39 | } 40 | 41 | void execute(String sql, [List args = const []]) { 42 | db.execute(sql, args); 43 | } 44 | 45 | void close() { 46 | db.dispose(); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /lib/src/database/types/schema.dart: -------------------------------------------------------------------------------- 1 | part of '../db.dart'; 2 | 3 | const _schema = {0: (_schema0Up, _schema0Down)}; 4 | 5 | // ---------- 0000 no permissions 6 | // -rwx------ 0700 read, write, & execute only for owner 7 | // -rwxrwx--- 0770 read, write, & execute for owner and group 8 | // -rwxrwxrwx 0777 read, write, & execute for owner, group and others 9 | // ---x--x--x 0111 execute 10 | // --w--w--w- 0222 write 11 | // --wx-wx-wx 0333 write & execute 12 | // -r--r--r-- 0444 read 13 | // -r-xr-xr-x 0555 read & execute 14 | // -rw-rw-rw- 0666 read & write 15 | // -rwxr----- 0740 owner can read, write, & execute; group can only read; others have no permissions 16 | 17 | const _schema0Up = ''' 18 | CREATE TABLE files ( 19 | path TEXT NOT NULL PRIMARY KEY, 20 | mode INTEGER NOT NULL DEFAULT (1), 21 | data BLOB, 22 | size INTEGER, 23 | link TEXT REFERENCES files(path), 24 | is_dir BOOLEAN NOT NULL DEFAULT (FALSE), 25 | accessed TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP), 26 | created TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP), 27 | modified TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP), 28 | changed TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP) 29 | ); 30 | 31 | CREATE TABLE temp_directories ( 32 | path TEXT NOT NULL PRIMARY KEY, 33 | created TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP) 34 | ); 35 | 36 | CREATE INDEX files_path ON files(path); 37 | CREATE INDEX files_link ON files(link); 38 | '''; 39 | 40 | extension type DatabaseFile(Row row) implements Row { 41 | String get path => row['path'] as String; 42 | 43 | int get mode => row['mode'] as int; 44 | 45 | Uint8List? get data { 46 | final data = row['data']; 47 | if (data == null) return null; 48 | return Uint8List.fromList(data as List); 49 | } 50 | 51 | int? get size => row['size'] as int?; 52 | 53 | String? get link => row['link'] as String?; 54 | 55 | bool get isDir { 56 | final val = row['is_dir']; 57 | if (val is int) return val != 0; 58 | if (val is bool) return val; 59 | return val == 'true'; 60 | } 61 | 62 | bool get isLink => link != null && link!.isNotEmpty; 63 | 64 | /// The time of the last change to the data of the file system object. 65 | DateTime get modified { 66 | final modified = row['modified']; 67 | if (modified is int) return DateTime.fromMillisecondsSinceEpoch(modified); 68 | return DateTime.parse(modified as String); 69 | } 70 | 71 | /// When the file system object was created. 72 | DateTime get created { 73 | final created = row['created']; 74 | if (created is int) return DateTime.fromMillisecondsSinceEpoch(created); 75 | return DateTime.parse(created as String); 76 | } 77 | 78 | /// The time of the last access to the data of the file system object. 79 | /// 80 | /// On Windows platforms, this may have 1 day granularity, and be 81 | /// out of date by an hour. 82 | DateTime get accessed { 83 | final accessed = row['accessed']; 84 | if (accessed is int) return DateTime.fromMillisecondsSinceEpoch(accessed); 85 | return DateTime.parse(accessed as String); 86 | } 87 | 88 | /// The time of the last change to the data or metadata of the file system 89 | /// object. 90 | /// 91 | /// On Windows platforms, this is instead the file creation time. 92 | DateTime get changed { 93 | final changed = row['changed']; 94 | if (changed is int) return DateTime.fromMillisecondsSinceEpoch(changed); 95 | return DateTime.parse(changed as String); 96 | } 97 | } 98 | 99 | extension type DatabaseTempDir(Row row) implements Row { 100 | String get path => row['path'] as String; 101 | 102 | DateTime get created { 103 | final created = row['created']; 104 | if (created is int) return DateTime.fromMillisecondsSinceEpoch(created); 105 | return DateTime.parse(created as String); 106 | } 107 | } 108 | 109 | const _schema0Down = ''' 110 | DROP TABLE files; 111 | DROP TABLE temp_directories; 112 | '''; 113 | -------------------------------------------------------------------------------- /lib/src/database/types/selectable.dart: -------------------------------------------------------------------------------- 1 | part of '../db.dart'; 2 | 3 | class Selectable { 4 | final CommonDatabase db; 5 | final String sql; 6 | final List args; 7 | final T Function(Row) mapper; 8 | 9 | Selectable(this.db, this.sql, this.args, this.mapper); 10 | 11 | Selectable map(R Function(Row) f) { 12 | return Selectable(db, sql, args, f); 13 | } 14 | 15 | List getAll() { 16 | final rows = db.select(sql, args); 17 | return rows.map(mapper).toList(); 18 | } 19 | 20 | T? getSingleOrNull() { 21 | final row = db.select(sql, args).firstOrNull; 22 | if (row == null) return null; 23 | return mapper(row); 24 | } 25 | 26 | T getSingle() { 27 | final row = db.select(sql, args).first; 28 | return mapper(row); 29 | } 30 | 31 | Stream> watch(Set tables) async* { 32 | yield getAll(); 33 | await for (final event in db.updates) { 34 | if (tables.contains(event.tableName)) { 35 | yield getAll(); 36 | } 37 | } 38 | } 39 | 40 | Stream watchSingleOrNull(Set tables) async* { 41 | yield getSingleOrNull(); 42 | await for (final event in db.updates) { 43 | if (tables.contains(event.tableName)) { 44 | yield getSingleOrNull(); 45 | } 46 | } 47 | } 48 | 49 | Stream watchSingle(Set tables) async* { 50 | yield getSingle(); 51 | await for (final event in db.updates) { 52 | if (tables.contains(event.tableName)) { 53 | yield getSingle(); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/src/file_system/fs.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: implementation_imports 2 | 3 | import 'dart:async'; 4 | import 'dart:convert'; 5 | import 'dart:math'; 6 | import 'dart:typed_data'; 7 | import 'dart:math' as math; 8 | 9 | import 'package:file/file.dart'; 10 | import 'package:file/src/common.dart' as common; 11 | import 'package:path/path.dart' as p; 12 | import 'package:sqlite3/common.dart'; 13 | 14 | import 'io.dart' as io; 15 | import 'utils.dart' as utils; 16 | import '../database/db.dart'; 17 | import 'io.dart'; 18 | 19 | part 'types/directory.dart'; 20 | part 'types/file_system.dart'; 21 | part 'types/file.dart'; 22 | part 'types/random_access_file.dart'; 23 | part 'types/file_io_sink.dart'; 24 | part 'types/file_system_entity.dart'; 25 | part 'types/link.dart'; 26 | part 'types/file_stat.dart'; 27 | part 'types/file_mode.dart'; 28 | part 'types/common.dart'; 29 | -------------------------------------------------------------------------------- /lib/src/file_system/io.dart: -------------------------------------------------------------------------------- 1 | export 'dart:io' 2 | show 3 | Directory, 4 | File, 5 | FileLock, 6 | FileMode, 7 | FileStat, 8 | FileSystemEntity, 9 | FileSystemEntityType, 10 | FileSystemEvent, 11 | FileSystemException, 12 | FileSystemCreateEvent, 13 | FileSystemDeleteEvent, 14 | FileSystemModifyEvent, 15 | FileSystemMoveEvent, 16 | IOException, 17 | IOSink, 18 | Link, 19 | OSError, 20 | RandomAccessFile; 21 | -------------------------------------------------------------------------------- /lib/src/file_system/types/common.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | /// Generates a path to use in error messages. 4 | typedef PathGenerator = dynamic Function(); 5 | 6 | /// Throws a `FileSystemException` if [object] is null. 7 | void checkExists(Object? object, PathGenerator path) { 8 | if (object == null) { 9 | throw common.noSuchFileOrDirectory(path() as String); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/file_system/types/directory.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | // Tracks a unique name for system temp directories, per filesystem 4 | // instance. 5 | final Expando _systemTempCounter = Expando(); 6 | 7 | class SqliteDirectory extends SqliteFileSystemEntity 8 | with common.DirectoryAddOnsMixin 9 | implements Directory { 10 | SqliteDirectory(super.fileSystem, super.path); 11 | 12 | @override 13 | io.FileSystemEntityType get expectedType => io.FileSystemEntityType.directory; 14 | 15 | @override 16 | Uri get uri { 17 | return Uri.directory(path, windows: p.style == p.Style.windows); 18 | } 19 | 20 | @override 21 | Directory get absolute { 22 | return fileSystem.directory(p.absolute(path)); 23 | } 24 | 25 | @override 26 | void createSync({bool recursive = false}) { 27 | if (existsSync()) return; 28 | if (!recursive) { 29 | final parent = fileSystem.directory(p.dirname(path)); 30 | _checkFile(parent.path); 31 | } 32 | _createAll(recursive: recursive); 33 | db.execute( 34 | 'INSERT INTO files (path, mode, data, size, link, is_dir, created, modified) VALUES (?, ?, NULL, 0, NULL, TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)', 35 | [path, SqliteFileMode.write.mode], 36 | ); 37 | controller.add( 38 | FileSystemCreateEvent( 39 | path, 40 | expectedType == FileSystemEntityType.directory, 41 | ), 42 | ); 43 | } 44 | 45 | @override 46 | Future create({bool recursive = false}) { 47 | createSync(recursive: recursive); 48 | return Future.value(this); 49 | } 50 | 51 | @override 52 | Directory createTempSync([String? prefix]) { 53 | prefix = '${prefix ?? ''}rand'; 54 | var fullPath = fileSystem.path.join(path, prefix); 55 | var dirname = fileSystem.path.dirname(fullPath); 56 | var basename = fileSystem.path.basename(fullPath); 57 | var node = fileSystem.directory(dirname); 58 | checkExists(node, () => dirname); 59 | var tempCounter = _systemTempCounter[fileSystem] ?? 0; 60 | String name() => '$basename$tempCounter'; 61 | while (node.childDirectory(name()).existsSync()) { 62 | tempCounter++; 63 | } 64 | _systemTempCounter[fileSystem] = tempCounter; 65 | var tempDir = node.childDirectory(name()); 66 | final dir = SqliteDirectory(fileSystem, tempDir.path); 67 | dir.createSync(); 68 | db.db.execute('INSERT INTO temp_directories (path) VALUES (?)', [dir.path]); 69 | return dir; 70 | } 71 | 72 | @override 73 | Future createTemp([String? prefix]) { 74 | return Future.value(createTempSync(prefix)); 75 | } 76 | 77 | @override 78 | List listSync({ 79 | bool recursive = false, 80 | bool followLinks = true, 81 | }) { 82 | List files; 83 | files = 84 | db 85 | .select('SELECT * FROM files WHERE path LIKE ?', [ 86 | p.join(path, '%'), 87 | ]) 88 | .getAll() 89 | .map(DatabaseFile.new) 90 | .toList(); 91 | if (!recursive) { 92 | files = 93 | files.where((file) => file.path != path).where((file) { 94 | final parent = fileSystem.path.dirname(file.path); 95 | return parent == path; 96 | }).toList(); 97 | } 98 | var results = 99 | files.map((file) { 100 | if (file.isDir) return fileSystem.directory(file.path); 101 | if (file.isLink) return fileSystem.link(file.path); 102 | return fileSystem.file(file.path); 103 | }).toList(); 104 | if (followLinks) { 105 | for (var i = 0; i < files.length; i++) { 106 | final file = files[i]; 107 | if (file.isLink) { 108 | final link = fileSystem.link(file.path); 109 | if (link.existsSync()) { 110 | final finalPath = link.resolveSymbolicLinksSync(); 111 | final stat = fileSystem.statSync(finalPath); 112 | if (stat.type == FileSystemEntityType.directory) { 113 | results[i] = fileSystem.directory(finalPath); 114 | } else if (stat.type == FileSystemEntityType.link) { 115 | results[i] = fileSystem.link(finalPath); 116 | } else { 117 | results[i] = fileSystem.file(finalPath); 118 | } 119 | } 120 | } 121 | } 122 | } 123 | return results; 124 | } 125 | 126 | @override 127 | Stream list({ 128 | bool recursive = false, 129 | bool followLinks = true, 130 | }) { 131 | return Stream.fromIterable( 132 | listSync(recursive: recursive, followLinks: followLinks), 133 | ); 134 | } 135 | 136 | @override 137 | void deleteSync({bool recursive = false}) { 138 | super.deleteSync(recursive: recursive); 139 | for (var entity in listSync(recursive: true)) { 140 | entity.deleteSync(recursive: true); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /lib/src/file_system/types/file.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | class SqliteFile extends SqliteFileSystemEntity implements File { 4 | SqliteFile(super.fileSystem, super.path); 5 | 6 | @override 7 | io.FileSystemEntityType get expectedType => io.FileSystemEntityType.file; 8 | 9 | @override 10 | File get absolute { 11 | return fileSystem.file(p.absolute(path)); 12 | } 13 | 14 | @override 15 | File copySync(String newPath) { 16 | _checkFile(path); 17 | db.execute( 18 | ''' 19 | INSERT INTO files (path, mode, data, size, link, is_dir, temp, created, modified) 20 | SELECT ?, mode, data, size, link, is_dir, temp, created, modified 21 | FROM files 22 | WHERE path = ? 23 | LIMIT 1 24 | ''', 25 | [newPath, path], 26 | ); 27 | controller.add( 28 | FileSystemCreateEvent( 29 | newPath, 30 | expectedType == io.FileSystemEntityType.directory, 31 | ), 32 | ); 33 | return fileSystem.file(newPath); 34 | } 35 | 36 | @override 37 | Future copy(String newPath) { 38 | return Future.value(copySync(newPath)); 39 | } 40 | 41 | @override 42 | void createSync({bool recursive = false, bool exclusive = false}) { 43 | if (existsSync()) { 44 | if (exclusive) { 45 | throw common.fileExists(path); 46 | } 47 | // File already exists and exclusive is false 48 | setLastModifiedSync(DateTime.now()); 49 | return; 50 | } 51 | if (!recursive) { 52 | final parent = fileSystem.directory(p.dirname(path)); 53 | _checkFile(parent.path); 54 | } 55 | _createAll(recursive: recursive); 56 | // File does not exist 57 | db.execute( 58 | 'INSERT INTO files (path, mode, data, size, link, is_dir) VALUES (?, ?, NULL, 0, NULL, FALSE)', 59 | [path, SqliteFileMode.write.mode], 60 | ); 61 | controller.add( 62 | FileSystemCreateEvent( 63 | path, 64 | expectedType == io.FileSystemEntityType.directory, 65 | ), 66 | ); 67 | } 68 | 69 | @override 70 | Future create({bool recursive = false, bool exclusive = false}) { 71 | createSync(recursive: recursive, exclusive: exclusive); 72 | return Future.value(this); 73 | } 74 | 75 | @override 76 | DateTime lastAccessedSync() { 77 | final file = _file(path); 78 | return file.accessed; 79 | } 80 | 81 | @override 82 | Future lastAccessed() { 83 | return Future.value(lastAccessedSync()); 84 | } 85 | 86 | @override 87 | DateTime lastModifiedSync() { 88 | final file = _file(path); 89 | return file.modified; 90 | } 91 | 92 | @override 93 | Future lastModified() { 94 | return Future.value(lastModifiedSync()); 95 | } 96 | 97 | @override 98 | int lengthSync() { 99 | final file = _file(path); 100 | return file.size ?? 0; 101 | } 102 | 103 | @override 104 | Future length() { 105 | return Future.value(lengthSync()); 106 | } 107 | 108 | @override 109 | RandomAccessFile openSync({FileMode mode = FileMode.read}) { 110 | Uint8List data = Uint8List(0); 111 | 112 | final file = _file(path); 113 | data = file.data ?? Uint8List(0); 114 | 115 | void truncate(int length) { 116 | data.length = length; 117 | writeAsBytesSync(data); 118 | } 119 | 120 | void write(Uint8List bytes) { 121 | data = bytes; 122 | writeAsBytesSync(data); 123 | } 124 | 125 | return RandomAccessFileImpl(fileSystem, path, mode, ( 126 | bytes: data, 127 | truncate: truncate, 128 | write: write, 129 | )); 130 | } 131 | 132 | @override 133 | Future open({FileMode mode = FileMode.read}) { 134 | return Future.value(openSync(mode: mode)); 135 | } 136 | 137 | @override 138 | Stream> openRead([int? start, int? end]) { 139 | final file = _file(path); 140 | final bytes = file.data ?? Uint8List(0); 141 | final view = Uint8List.view( 142 | bytes.buffer, 143 | start ?? 0, 144 | end ?? bytes.lengthInBytes, 145 | ); 146 | return Stream.value(view.toList()); 147 | } 148 | 149 | @override 150 | IOSink openWrite({FileMode mode = FileMode.write, Encoding encoding = utf8}) { 151 | if (!utils.isWriteMode(mode)) { 152 | throw ArgumentError.value( 153 | mode, 154 | 'mode', 155 | 'Must be either WRITE, APPEND, WRITE_ONLY, or WRITE_ONLY_APPEND', 156 | ); 157 | } 158 | return _FileSink.fromFile(this, mode, encoding); 159 | } 160 | 161 | @override 162 | Future readAsBytes() { 163 | return Future.value(readAsBytesSync()); 164 | } 165 | 166 | @override 167 | Uint8List readAsBytesSync() { 168 | final file = _file(path); 169 | setLastAccessedSync(DateTime.now()); 170 | return file.data ?? Uint8List(0); 171 | } 172 | 173 | @override 174 | Future> readAsLines({Encoding encoding = utf8}) { 175 | return Future.value(readAsLinesSync(encoding: encoding)); 176 | } 177 | 178 | @override 179 | List readAsLinesSync({Encoding encoding = utf8}) { 180 | return encoding.decode(readAsBytesSync()).split('\n'); 181 | } 182 | 183 | @override 184 | Future readAsString({Encoding encoding = utf8}) { 185 | return Future.value(readAsStringSync(encoding: encoding)); 186 | } 187 | 188 | @override 189 | String readAsStringSync({Encoding encoding = utf8}) { 190 | return encoding.decode(readAsBytesSync()); 191 | } 192 | 193 | @override 194 | void setLastAccessedSync(DateTime time) { 195 | _checkFile(path); 196 | db.execute('UPDATE files SET accessed = ? WHERE path = ?', [ 197 | time.millisecondsSinceEpoch, 198 | path, 199 | ]); 200 | } 201 | 202 | @override 203 | Future setLastAccessed(DateTime time) { 204 | setLastAccessedSync(time); 205 | return Future.value(); 206 | } 207 | 208 | @override 209 | void setLastModifiedSync(DateTime time) { 210 | _checkFile(path); 211 | db.execute('UPDATE files SET modified = ? WHERE path = ?', [ 212 | time.millisecondsSinceEpoch, 213 | path, 214 | ]); 215 | controller.add( 216 | FileSystemModifyEvent( 217 | path, 218 | expectedType == io.FileSystemEntityType.directory, 219 | false, 220 | ), 221 | ); 222 | } 223 | 224 | @override 225 | Future setLastModified(DateTime time) { 226 | setLastModifiedSync(time); 227 | return Future.value(); 228 | } 229 | 230 | void setLastChangedSync(DateTime time) { 231 | _checkFile(path); 232 | db.execute('UPDATE files SET changed = ? WHERE path = ?', [ 233 | time.millisecondsSinceEpoch, 234 | path, 235 | ]); 236 | } 237 | 238 | Future setLastChanged(DateTime time) { 239 | setLastChangedSync(time); 240 | return Future.value(); 241 | } 242 | 243 | @override 244 | void writeAsBytesSync( 245 | List bytes, { 246 | FileMode mode = SqliteFileMode.write, 247 | bool flush = false, 248 | }) { 249 | int modeValue = SqliteFileMode.write.mode; 250 | if (mode is SqliteFileMode) { 251 | modeValue = mode.mode; 252 | } 253 | if (![ 254 | SqliteFileMode.write, 255 | SqliteFileMode.writeOnly, 256 | SqliteFileMode.writeOnlyAppend, 257 | SqliteFileMode.append, 258 | ].map((e) => e.mode).contains(modeValue)) { 259 | throw ArgumentError.value( 260 | mode, 261 | 'mode', 262 | 'Must be either WRITE, APPEND, WRITE_ONLY, or WRITE_ONLY_APPEND', 263 | ); 264 | } 265 | final file = _file(path); 266 | if (modeValue == SqliteFileMode.writeOnlyAppend.mode || 267 | modeValue == SqliteFileMode.append.mode) { 268 | bytes = utils.concatBytes(file.data ?? [], bytes); 269 | } 270 | db.execute( 271 | 'UPDATE files SET data = ?, size = ?, modified = ?, changed = ?, accessed = ?, mode = ? WHERE path = ?', 272 | [ 273 | bytes, 274 | bytes.length, 275 | DateTime.now().millisecondsSinceEpoch, 276 | DateTime.now().millisecondsSinceEpoch, 277 | DateTime.now().millisecondsSinceEpoch, 278 | modeValue, 279 | path, 280 | ], 281 | ); 282 | controller.add( 283 | FileSystemModifyEvent( 284 | path, 285 | expectedType == io.FileSystemEntityType.directory, 286 | utils.compareBytes(file.data, bytes), 287 | ), 288 | ); 289 | } 290 | 291 | @override 292 | Future writeAsBytes( 293 | List bytes, { 294 | FileMode mode = FileMode.write, 295 | bool flush = false, 296 | }) { 297 | writeAsBytesSync(bytes, mode: mode, flush: flush); 298 | return Future.value(this); 299 | } 300 | 301 | @override 302 | void writeAsStringSync( 303 | String contents, { 304 | FileMode mode = FileMode.write, 305 | Encoding encoding = utf8, 306 | bool flush = false, 307 | }) { 308 | writeAsBytesSync(encoding.encode(contents), mode: mode, flush: flush); 309 | } 310 | 311 | @override 312 | Future writeAsString( 313 | String contents, { 314 | FileMode mode = FileMode.write, 315 | Encoding encoding = utf8, 316 | bool flush = false, 317 | }) { 318 | writeAsStringSync(contents, mode: mode, encoding: encoding, flush: flush); 319 | return Future.value(this); 320 | } 321 | 322 | SqliteFile get _resolvedBackingOrCreate { 323 | var file = db.file(path); 324 | if (file == null) createSync(); 325 | return this; 326 | } 327 | 328 | void _truncateIfNecessary(SqliteFile? file, io.FileMode mode) { 329 | if (mode == io.FileMode.write || mode == io.FileMode.writeOnly) { 330 | if (file == null) createSync(); 331 | writeAsBytesSync([]); 332 | } 333 | } 334 | } 335 | -------------------------------------------------------------------------------- /lib/src/file_system/types/file_io_sink.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | /// Implementation of an [io.IOSink] that's backed by a [FileNode]. 4 | class _FileSink implements io.IOSink { 5 | factory _FileSink.fromFile( 6 | SqliteFile file, 7 | io.FileMode mode, 8 | Encoding encoding, 9 | ) { 10 | late SqliteFile node; 11 | Exception? deferredException; 12 | 13 | // Resolve the backing immediately to ensure that the [FileNode] we write 14 | // to is the same as when [openWrite] was called. This can matter if the 15 | // file is moved or removed while open. 16 | try { 17 | node = file._resolvedBackingOrCreate; 18 | } on Exception catch (e) { 19 | // For behavioral consistency with [LocalFile], do not report failures 20 | // immediately. 21 | deferredException = e; 22 | } 23 | 24 | var future = Future.microtask(() { 25 | if (deferredException != null) { 26 | throw deferredException; 27 | } 28 | file._truncateIfNecessary(node, mode); 29 | return node; 30 | }); 31 | return _FileSink._(future, encoding); 32 | } 33 | 34 | _FileSink._(Future node, this.encoding) : _pendingWrites = node; 35 | 36 | final Completer _completer = Completer(); 37 | 38 | @override 39 | Encoding encoding; 40 | 41 | Future _pendingWrites; 42 | Completer? _streamCompleter; 43 | bool _isClosed = false; 44 | 45 | bool get isStreaming => !(_streamCompleter?.isCompleted ?? true); 46 | 47 | @override 48 | void add(List data) { 49 | _checkNotStreaming(); 50 | if (_isClosed) { 51 | throw StateError('StreamSink is closed'); 52 | } 53 | 54 | _addData(data); 55 | } 56 | 57 | @override 58 | void write(Object? obj) => add(encoding.encode(obj?.toString() ?? 'null')); 59 | 60 | @override 61 | void writeAll(Iterable objects, [String separator = '']) { 62 | var firstIter = true; 63 | for (dynamic obj in objects) { 64 | if (!firstIter) { 65 | write(separator); 66 | } 67 | firstIter = false; 68 | write(obj); 69 | } 70 | } 71 | 72 | @override 73 | void writeln([Object? obj = '']) { 74 | write(obj); 75 | write('\n'); 76 | } 77 | 78 | @override 79 | void writeCharCode(int charCode) { 80 | write(String.fromCharCode(charCode)); 81 | } 82 | 83 | @override 84 | void addError(Object error, [StackTrace? stackTrace]) { 85 | _checkNotStreaming(); 86 | _completer.completeError(error, stackTrace); 87 | } 88 | 89 | @override 90 | Future addStream(Stream> stream) { 91 | _checkNotStreaming(); 92 | _streamCompleter = Completer(); 93 | 94 | stream.listen( 95 | _addData, 96 | cancelOnError: true, 97 | onError: (Object error, StackTrace stackTrace) { 98 | _streamCompleter!.completeError(error, stackTrace); 99 | _streamCompleter = null; 100 | }, 101 | onDone: () { 102 | _streamCompleter!.complete(); 103 | _streamCompleter = null; 104 | }, 105 | ); 106 | return _streamCompleter!.future; 107 | } 108 | 109 | @override 110 | Future flush() { 111 | _checkNotStreaming(); 112 | return _pendingWrites; 113 | } 114 | 115 | @override 116 | Future close() { 117 | _checkNotStreaming(); 118 | if (!_isClosed) { 119 | _isClosed = true; 120 | _pendingWrites.then( 121 | (_) => _completer.complete(), 122 | onError: _completer.completeError, 123 | ); 124 | } 125 | return _completer.future; 126 | } 127 | 128 | @override 129 | Future get done => _completer.future; 130 | 131 | void _addData(List data) { 132 | _pendingWrites = _pendingWrites.then((SqliteFile node) { 133 | node.writeAsBytesSync(data, mode: io.FileMode.writeOnly, flush: true); 134 | return node; 135 | }); 136 | } 137 | 138 | void _checkNotStreaming() { 139 | if (isStreaming) { 140 | throw StateError('StreamSink is bound to a stream'); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /lib/src/file_system/types/file_mode.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | /// The modes in which a [File] can be opened. 4 | class SqliteFileMode implements FileMode { 5 | /// The mode for opening a file only for reading. 6 | static const read = SqliteFileMode._internal(0); 7 | 8 | /// Mode for opening a file for reading and writing. The file is 9 | /// overwritten if it already exists. The file is created if it does not 10 | /// already exist. 11 | static const write = SqliteFileMode._internal(1); 12 | 13 | /// Mode for opening a file for reading and writing to the 14 | /// end of it. The file is created if it does not already exist. 15 | static const append = SqliteFileMode._internal(2); 16 | 17 | /// Mode for opening a file for writing *only*. The file is 18 | /// overwritten if it already exists. The file is created if it does not 19 | /// already exist. 20 | static const writeOnly = SqliteFileMode._internal(3); 21 | 22 | /// Mode for opening a file for writing *only* to the 23 | /// end of it. The file is created if it does not already exist. 24 | static const writeOnlyAppend = SqliteFileMode._internal(4); 25 | 26 | final int mode; 27 | 28 | const SqliteFileMode._internal(this.mode); 29 | } 30 | -------------------------------------------------------------------------------- /lib/src/file_system/types/file_stat.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | class SqliteFileStat implements FileStat { 4 | SqliteFileStat._(this.file); 5 | 6 | final DatabaseFile file; 7 | 8 | static FileStat notFound = const _NotFound(); 9 | 10 | @override 11 | DateTime get accessed => file.accessed; 12 | 13 | @override 14 | DateTime get changed => file.changed; 15 | 16 | @override 17 | DateTime get modified => file.modified; 18 | 19 | @override 20 | int get mode => file.mode; 21 | 22 | @override 23 | String modeString() { 24 | var permissions = mode & 0xFFF; 25 | var codes = const [ 26 | '---', 27 | '--x', 28 | '-w-', 29 | '-wx', 30 | 'r--', 31 | 'r-x', 32 | 'rw-', 33 | 'rwx', 34 | ]; 35 | var result = []; 36 | result 37 | ..add(codes[(permissions >> 6) & 0x7]) 38 | ..add(codes[(permissions >> 3) & 0x7]) 39 | ..add(codes[permissions & 0x7]); 40 | return result.join(); 41 | } 42 | 43 | @override 44 | int get size => file.size ?? -1; 45 | 46 | @override 47 | FileSystemEntityType get type { 48 | if (file.isDir) return FileSystemEntityType.directory; 49 | if (file.isLink) return FileSystemEntityType.link; 50 | return FileSystemEntityType.file; 51 | } 52 | } 53 | 54 | class _NotFound implements FileStat { 55 | const _NotFound(); 56 | 57 | @override 58 | DateTime get accessed => DateTime(0); 59 | 60 | @override 61 | DateTime get changed => DateTime(0); 62 | 63 | @override 64 | DateTime get modified => DateTime(0); 65 | 66 | @override 67 | int get mode => 0; 68 | 69 | @override 70 | String modeString() => ''; 71 | 72 | @override 73 | int get size => -1; 74 | 75 | @override 76 | FileSystemEntityType get type => FileSystemEntityType.notFound; 77 | } 78 | -------------------------------------------------------------------------------- /lib/src/file_system/types/file_system.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | class SqliteFileSystem extends FileSystem { 4 | final DB db; 5 | 6 | SqliteFileSystem(this.db) { 7 | deleteTempDirectories(); 8 | } 9 | 10 | static SqliteFileSystem fromDb(CommonDatabase db) { 11 | return SqliteFileSystem(DB(db)); 12 | } 13 | 14 | late Directory _currentDirectory = () { 15 | final dir = directory('/'); 16 | if (!dir.existsSync()) { 17 | dir.createSync(recursive: true); 18 | } 19 | return dir; 20 | }(); 21 | 22 | @override 23 | Directory get currentDirectory => _currentDirectory; 24 | 25 | @override 26 | set currentDirectory(dynamic value) { 27 | _currentDirectory = directory(utils.resolvePath(value)); 28 | } 29 | 30 | @override 31 | late final Directory systemTempDirectory = directory( 32 | '${DateTime.now().millisecondsSinceEpoch}-${Random().nextInt(1000)}/', 33 | ); 34 | 35 | @override 36 | Directory directory(path) { 37 | return SqliteDirectory(this, utils.resolvePath(path)); 38 | } 39 | 40 | @override 41 | File file(path) { 42 | return SqliteFile(this, utils.resolvePath(path)); 43 | } 44 | 45 | @override 46 | Link link(path) { 47 | return SqliteLink(this, utils.resolvePath(path)); 48 | } 49 | 50 | @override 51 | bool identicalSync(String path1, String path2) { 52 | final a = db.file(path1); 53 | final b = db.file(path2); 54 | return a == b; 55 | } 56 | 57 | @override 58 | Future identical(String path1, String path2) { 59 | return Future.value(identicalSync(path1, path2)); 60 | } 61 | 62 | @override 63 | bool get isWatchSupported => true; 64 | 65 | @override 66 | p.Context get path => p.context; 67 | 68 | @override 69 | FileStat statSync(String path) { 70 | final file = db.file(path); 71 | if (file == null) return SqliteFileStat.notFound; 72 | return SqliteFileStat._(file); 73 | } 74 | 75 | @override 76 | Future stat(String path) { 77 | return Future.value(statSync(path)); 78 | } 79 | 80 | @override 81 | FileSystemEntityType typeSync(String path, {bool followLinks = true}) { 82 | var file = db.file(path); 83 | if (file == null) return FileSystemEntityType.notFound; 84 | if (followLinks) { 85 | while (file != null && file.isLink) { 86 | file = db.file(file.link!); 87 | } 88 | } 89 | if (file == null) return FileSystemEntityType.notFound; 90 | if (file.isDir) return FileSystemEntityType.directory; 91 | if (file.isLink) return FileSystemEntityType.link; 92 | return FileSystemEntityType.file; 93 | } 94 | 95 | @override 96 | Future type(String path, {bool followLinks = true}) { 97 | return Future.value(typeSync(path, followLinks: followLinks)); 98 | } 99 | 100 | void deleteTempDirectories() { 101 | final files = 102 | db 103 | .select('SELECT * FROM temp_directories') 104 | .map(DatabaseTempDir.new) 105 | .getAll(); 106 | for (var file in files) { 107 | final dir = directory(file.path); 108 | if (dir.existsSync()) { 109 | dir.deleteSync(recursive: true); 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /lib/src/file_system/types/file_system_entity.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | abstract class SqliteFileSystemEntity extends FileSystemEntity { 4 | SqliteFileSystemEntity(this.fileSystem, this.path); 5 | 6 | io.FileSystemEntityType get expectedType; 7 | 8 | late final DB db = fileSystem.db; 9 | 10 | @override 11 | final SqliteFileSystem fileSystem; 12 | 13 | @override 14 | final String path; 15 | 16 | static final _controller = StreamController.broadcast(); 17 | StreamController get controller => _controller; 18 | 19 | void _checkFile(String path) { 20 | var file = db.file(path); 21 | if (file == null) throw common.noSuchFileOrDirectory(path); 22 | } 23 | 24 | DatabaseFile _file(String path) { 25 | var file = db.file(path); 26 | if (file == null) throw common.noSuchFileOrDirectory(path); 27 | return file; 28 | } 29 | 30 | void _createAll({bool recursive = false}) { 31 | final parts = p.split(path); 32 | for (var i = 1; i < parts.length; i++) { 33 | final dir = fileSystem.directory(p.joinAll(parts.sublist(0, i))); 34 | dir.createSync(recursive: recursive); 35 | } 36 | } 37 | 38 | @override 39 | Uri get uri { 40 | return Uri.file(path, windows: p.style == p.Style.windows); 41 | } 42 | 43 | @override 44 | String get dirname => p.dirname(path); 45 | 46 | @override 47 | String get basename => p.basename(path); 48 | 49 | @override 50 | FileSystemEntity get absolute => fileSystem.file(p.absolute(path)); 51 | 52 | @override 53 | bool get isAbsolute => p.isAbsolute(path); 54 | 55 | @override 56 | void deleteSync({bool recursive = false}) { 57 | db.deleteFile(path); 58 | controller.add(FileSystemDeleteEvent(path, expectedType == io.FileSystemEntityType.directory)); 59 | } 60 | 61 | @override 62 | Future delete({bool recursive = false}) { 63 | deleteSync(recursive: recursive); 64 | return Future.value(this as T); 65 | } 66 | 67 | @override 68 | bool existsSync() { 69 | final file = db.file(path); 70 | return file != null; 71 | } 72 | 73 | @override 74 | Future exists() { 75 | return Future.value(existsSync()); 76 | } 77 | 78 | @override 79 | Directory get parent { 80 | final dirPath = p.dirname(path); 81 | return fileSystem.directory(dirPath); 82 | } 83 | 84 | @override 85 | T renameSync(String newPath) { 86 | _checkFile(path); 87 | db.execute('UPDATE files SET path = ? WHERE path = ?', [newPath, path]); 88 | // TODO: Rename references 89 | controller.add(FileSystemMoveEvent(path, expectedType == io.FileSystemEntityType.directory, newPath)); 90 | return fileSystem.file(newPath) as T; 91 | } 92 | 93 | @override 94 | Future rename(String newPath) { 95 | return Future.value(renameSync(newPath)); 96 | } 97 | 98 | @override 99 | Future resolveSymbolicLinks() { 100 | return Future.value(resolveSymbolicLinksSync()); 101 | } 102 | 103 | @override 104 | String resolveSymbolicLinksSync() { 105 | if (path.isEmpty) { 106 | throw common.noSuchFileOrDirectory(path); 107 | } 108 | final visited = {}; 109 | var current = _file(path); 110 | while (current.link != null && current.link!.isNotEmpty) { 111 | if (visited.contains(current.path)) { 112 | throw LinkCycleException(current.path); 113 | } 114 | visited.add(current.path); 115 | current = _file(current.link!); 116 | } 117 | return fileSystem.path.normalize(current.path); 118 | } 119 | 120 | @override 121 | FileStat statSync() { 122 | final file = db.file(path); 123 | if (file != null) return SqliteFileStat.notFound; 124 | return SqliteFileStat._(file!); 125 | } 126 | 127 | @override 128 | Future stat() { 129 | return Future.value(statSync()); 130 | } 131 | 132 | @override 133 | Stream watch({int events = FileSystemEvent.all, bool recursive = false}) { 134 | var s = _controller.stream; 135 | s = s.where((event) => event.type & events != 0); 136 | if (!recursive) s = s.where((e) => e.path == path); 137 | return s; 138 | } 139 | } 140 | 141 | class LinkCycleException implements Exception { 142 | LinkCycleException(this.path); 143 | 144 | final String path; 145 | 146 | @override 147 | String toString() => 'Link cycle detected at $path'; 148 | } 149 | -------------------------------------------------------------------------------- /lib/src/file_system/types/link.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | class SqliteLink extends SqliteFileSystemEntity implements Link { 4 | SqliteLink(super.fileSystem, super.path); 5 | 6 | @override 7 | io.FileSystemEntityType get expectedType => io.FileSystemEntityType.link; 8 | 9 | @override 10 | void createSync(String target, {bool recursive = false}) { 11 | if (existsSync()) { 12 | throw common.fileExists(path); 13 | } 14 | db.execute( 15 | 'INSERT INTO files (path, mode, link, is_dir) VALUES (?, ?, ?, FALSE)', 16 | [path, SqliteFileMode.write.mode, target], 17 | ); 18 | controller.add( 19 | FileSystemCreateEvent( 20 | path, 21 | expectedType == FileSystemEntityType.directory, 22 | ), 23 | ); 24 | } 25 | 26 | @override 27 | Future create(String target, {bool recursive = false}) { 28 | createSync(target, recursive: recursive); 29 | return Future.value(this); 30 | } 31 | 32 | @override 33 | String targetSync() { 34 | final file = _file(path); 35 | if (file.link == null || file.link!.isEmpty) { 36 | throw common.noSuchFileOrDirectory(path); 37 | } 38 | return file.link as String; 39 | } 40 | 41 | @override 42 | Future target() { 43 | return Future.value(targetSync()); 44 | } 45 | 46 | @override 47 | void updateSync(String target) { 48 | final file = _file(path); 49 | final changed = file.link != target; 50 | db.execute('UPDATE files SET link = ? WHERE path = ?', [target, path]); 51 | controller.add( 52 | FileSystemModifyEvent( 53 | path, 54 | expectedType == FileSystemEntityType.directory, 55 | changed, 56 | ), 57 | ); 58 | } 59 | 60 | @override 61 | Future update(String target) { 62 | updateSync(target); 63 | return Future.value(this); 64 | } 65 | 66 | @override 67 | Link renameSync(String newPath) { 68 | _checkFile(path); 69 | db.execute('UPDATE files SET path = ? WHERE path = ?', [newPath, path]); 70 | controller.add( 71 | FileSystemMoveEvent( 72 | path, 73 | expectedType == FileSystemEntityType.directory, 74 | newPath, 75 | ), 76 | ); 77 | return fileSystem.link(newPath); 78 | } 79 | 80 | @override 81 | Future rename(String newPath) { 82 | return Future.value(renameSync(newPath)); 83 | } 84 | 85 | @override 86 | Link get absolute => fileSystem.link(p.absolute(path)); 87 | } 88 | -------------------------------------------------------------------------------- /lib/src/file_system/types/random_access_file.dart: -------------------------------------------------------------------------------- 1 | part of '../fs.dart'; 2 | 3 | class RandomAccessFileImpl implements RandomAccessFile { 4 | final SqliteFileSystem fileSystem; 5 | 6 | final FileMode _mode; 7 | bool _isOpen = true; 8 | int _position = 0; 9 | 10 | @override 11 | final String path; 12 | 13 | final ({ 14 | Uint8List bytes, 15 | void Function(Uint8List) write, 16 | void Function(int length) truncate, 17 | }) 18 | _node; 19 | 20 | late final DB db = fileSystem.db; 21 | 22 | RandomAccessFileImpl(this.fileSystem, this.path, this._mode, this._node) { 23 | switch (_mode) { 24 | case io.FileMode.read: 25 | break; 26 | case io.FileMode.write: 27 | case io.FileMode.writeOnly: 28 | truncateSync(0); 29 | break; 30 | case io.FileMode.append: 31 | case io.FileMode.writeOnlyAppend: 32 | _position = lengthSync(); 33 | break; 34 | default: 35 | // [FileMode] provides no way of retrieving its value or name. 36 | throw UnimplementedError('Unsupported FileMode'); 37 | } 38 | } 39 | 40 | /// Whether an asynchronous operation is pending. 41 | /// 42 | /// See [_asyncWrapper] for details. 43 | bool get _asyncOperationPending => __asyncOperationPending; 44 | 45 | set _asyncOperationPending(bool value) { 46 | assert(__asyncOperationPending != value); 47 | __asyncOperationPending = value; 48 | } 49 | 50 | bool __asyncOperationPending = false; 51 | 52 | /// Throws a [io.FileSystemException] if an operation is attempted on a file 53 | /// that is not open. 54 | void _checkOpen() { 55 | if (!_isOpen) { 56 | throw io.FileSystemException('File closed', path); 57 | } 58 | } 59 | 60 | /// Throws a [io.FileSystemException] if attempting to read from a file that 61 | /// has not been opened for reading. 62 | void _checkReadable(String operation) { 63 | switch (_mode) { 64 | case io.FileMode.read: 65 | case io.FileMode.write: 66 | case io.FileMode.append: 67 | return; 68 | case io.FileMode.writeOnly: 69 | case io.FileMode.writeOnlyAppend: 70 | default: 71 | throw io.FileSystemException( 72 | '$operation failed', 73 | path, 74 | common.badFileDescriptor(path).osError, 75 | ); 76 | } 77 | } 78 | 79 | /// Throws a [io.FileSystemException] if attempting to read from a file that 80 | /// has not been opened for writing. 81 | void _checkWritable(String operation) { 82 | if (utils.isWriteMode(_mode)) { 83 | return; 84 | } 85 | 86 | throw io.FileSystemException( 87 | '$operation failed', 88 | path, 89 | common.badFileDescriptor(path).osError, 90 | ); 91 | } 92 | 93 | /// Throws a [io.FileSystemException] if attempting to perform an operation 94 | /// while an asynchronous operation is already in progress. 95 | /// 96 | /// See [_asyncWrapper] for details. 97 | void _checkAsync() { 98 | if (_asyncOperationPending) { 99 | throw io.FileSystemException( 100 | 'An async operation is currently pending', 101 | path, 102 | ); 103 | } 104 | } 105 | 106 | /// Wraps a synchronous function to make it appear asynchronous. 107 | /// 108 | /// [_asyncOperationPending], [_checkAsync], and [_asyncWrapper] are used to 109 | /// mimic [io.RandomAccessFile]'s enforcement that only one asynchronous 110 | /// operation is pending for a [io.RandomAccessFile] instance. Since 111 | /// [MemoryFileSystem]-based classes are likely to be used in tests, fidelity 112 | /// is important to catch errors that might occur in production. 113 | /// 114 | /// [_asyncWrapper] does not call [f] directly since setting and unsetting 115 | /// [_asyncOperationPending] synchronously would not be meaningful. We 116 | /// instead execute [f] through a [Future.delayed] callback to better simulate 117 | /// asynchrony. 118 | Future _asyncWrapper(R Function() f) async { 119 | _checkAsync(); 120 | 121 | _asyncOperationPending = true; 122 | try { 123 | return await Future.delayed(Duration.zero, () { 124 | // Temporarily reset [_asyncOpPending] in case [f]'s has its own 125 | // checks for pending asynchronous operations. 126 | _asyncOperationPending = false; 127 | try { 128 | return f(); 129 | } finally { 130 | _asyncOperationPending = true; 131 | } 132 | }); 133 | } finally { 134 | _asyncOperationPending = false; 135 | } 136 | } 137 | 138 | @override 139 | Future close() async => _asyncWrapper(closeSync); 140 | 141 | @override 142 | void closeSync() { 143 | _checkOpen(); 144 | _isOpen = false; 145 | } 146 | 147 | @override 148 | Future flush() async { 149 | await _asyncWrapper(flushSync); 150 | return this; 151 | } 152 | 153 | @override 154 | void flushSync() { 155 | _checkOpen(); 156 | _checkAsync(); 157 | } 158 | 159 | @override 160 | Future length() => _asyncWrapper(lengthSync); 161 | 162 | @override 163 | int lengthSync() { 164 | _checkOpen(); 165 | _checkAsync(); 166 | return _node.bytes.length; 167 | } 168 | 169 | @override 170 | Future lock([ 171 | io.FileLock mode = io.FileLock.exclusive, 172 | int start = 0, 173 | int end = -1, 174 | ]) async { 175 | await _asyncWrapper(() => lockSync(mode, start, end)); 176 | return this; 177 | } 178 | 179 | @override 180 | void lockSync([ 181 | io.FileLock mode = io.FileLock.exclusive, 182 | int start = 0, 183 | int end = -1, 184 | ]) { 185 | _checkOpen(); 186 | _checkAsync(); 187 | // TODO(jamesderlin): Implement, https://github.com/google/file.dart/issues/140 188 | throw UnimplementedError('TODO'); 189 | } 190 | 191 | @override 192 | Future position() => _asyncWrapper(positionSync); 193 | 194 | @override 195 | int positionSync() { 196 | _checkOpen(); 197 | _checkAsync(); 198 | return _position; 199 | } 200 | 201 | @override 202 | Future read(int bytes) => _asyncWrapper(() => readSync(bytes)); 203 | 204 | @override 205 | Uint8List readSync(int bytes) { 206 | _checkOpen(); 207 | _checkAsync(); 208 | _checkReadable('read'); 209 | // TODO(jamesderlin): Check for integer overflow. 210 | final int end = math.min(_position + bytes, lengthSync()); 211 | final copy = _node.bytes.sublist(_position, end); 212 | _position = end; 213 | return copy; 214 | } 215 | 216 | @override 217 | Future readByte() => _asyncWrapper(readByteSync); 218 | 219 | @override 220 | int readByteSync() { 221 | _checkOpen(); 222 | _checkAsync(); 223 | _checkReadable('readByte'); 224 | 225 | if (_position >= lengthSync()) { 226 | return -1; 227 | } 228 | return _node.bytes[_position++]; 229 | } 230 | 231 | @override 232 | Future readInto(List buffer, [int start = 0, int? end]) => 233 | _asyncWrapper(() => readIntoSync(buffer, start, end)); 234 | 235 | @override 236 | int readIntoSync(List buffer, [int start = 0, int? end]) { 237 | _checkOpen(); 238 | _checkAsync(); 239 | _checkReadable('readInto'); 240 | 241 | end = RangeError.checkValidRange(start, end, buffer.length); 242 | 243 | final length = lengthSync(); 244 | int i; 245 | for (i = start; i < end && _position < length; i += 1, _position += 1) { 246 | buffer[i] = _node.bytes[_position]; 247 | } 248 | return i - start; 249 | } 250 | 251 | @override 252 | Future setPosition(int position) async { 253 | await _asyncWrapper(() => setPositionSync(position)); 254 | return this; 255 | } 256 | 257 | @override 258 | void setPositionSync(int position) { 259 | _checkOpen(); 260 | _checkAsync(); 261 | 262 | if (position < 0) { 263 | throw io.FileSystemException( 264 | 'setPosition failed', 265 | path, 266 | common.invalidArgument(path).osError, 267 | ); 268 | } 269 | 270 | // Empirical testing indicates that setting the position to be beyond the 271 | // end of the file is legal and will zero-fill upon the next write. 272 | _position = position; 273 | } 274 | 275 | @override 276 | Future truncate(int length) async { 277 | await _asyncWrapper(() => truncateSync(length)); 278 | return this; 279 | } 280 | 281 | @override 282 | void truncateSync(int length) { 283 | _checkOpen(); 284 | _checkAsync(); 285 | 286 | if (length < 0 || !utils.isWriteMode(_mode)) { 287 | throw io.FileSystemException( 288 | 'truncate failed', 289 | path, 290 | common.invalidArgument(path).osError, 291 | ); 292 | } 293 | 294 | final oldLength = lengthSync(); 295 | if (length < oldLength) { 296 | _node.truncate(length); 297 | 298 | // [_position] is intentionally left untouched to match the observed 299 | // behavior of [RandomAccessFile]. 300 | } else if (length > oldLength) { 301 | _node.write(Uint8List(length - oldLength)); 302 | } 303 | assert(lengthSync() == length); 304 | } 305 | 306 | @override 307 | Future unlock([int start = 0, int end = -1]) async { 308 | await _asyncWrapper(() => unlockSync(start, end)); 309 | return this; 310 | } 311 | 312 | @override 313 | void unlockSync([int start = 0, int end = -1]) { 314 | _checkOpen(); 315 | _checkAsync(); 316 | // TODO(jamesderlin): Implement, https://github.com/google/file.dart/issues/140 317 | throw UnimplementedError('TODO'); 318 | } 319 | 320 | @override 321 | Future writeByte(int value) async { 322 | await _asyncWrapper(() => writeByteSync(value)); 323 | return this; 324 | } 325 | 326 | @override 327 | int writeByteSync(int value) { 328 | _checkOpen(); 329 | _checkAsync(); 330 | _checkWritable('writeByte'); 331 | 332 | // [Uint8List] will truncate values to 8-bits automatically, so we don't 333 | // need to check [value]. 334 | 335 | var length = lengthSync(); 336 | if (_position >= length) { 337 | // If [_position] is out of bounds, [RandomAccessFile] zero-fills the 338 | // file. 339 | truncateSync(_position + 1); 340 | length = lengthSync(); 341 | } 342 | assert(_position < length); 343 | _node.bytes[_position++] = value; 344 | 345 | // Despite what the documentation states, [RandomAccessFile.writeByteSync] 346 | // always seems to return 1, even if we had to extend the file for an out of 347 | // bounds write. See https://github.com/dart-lang/sdk/issues/42298. 348 | return 1; 349 | } 350 | 351 | @override 352 | Future writeFrom( 353 | List buffer, [ 354 | int start = 0, 355 | int? end, 356 | ]) async { 357 | await _asyncWrapper(() => writeFromSync(buffer, start, end)); 358 | return this; 359 | } 360 | 361 | @override 362 | void writeFromSync(List buffer, [int start = 0, int? end]) { 363 | _checkOpen(); 364 | _checkAsync(); 365 | _checkWritable('writeFrom'); 366 | 367 | end = RangeError.checkValidRange(start, end, buffer.length); 368 | 369 | final writeByteCount = end - start; 370 | final endPosition = _position + writeByteCount; 371 | 372 | if (endPosition > lengthSync()) { 373 | truncateSync(endPosition); 374 | } 375 | 376 | _node.bytes.setRange(_position, endPosition, buffer, start); 377 | _position = endPosition; 378 | } 379 | 380 | @override 381 | Future writeString( 382 | String string, { 383 | Encoding encoding = utf8, 384 | }) async { 385 | await _asyncWrapper(() => writeStringSync(string, encoding: encoding)); 386 | return this; 387 | } 388 | 389 | @override 390 | void writeStringSync(String string, {Encoding encoding = utf8}) { 391 | writeFromSync(encoding.encode(string)); 392 | } 393 | } 394 | -------------------------------------------------------------------------------- /lib/src/file_system/utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:collection/collection.dart'; 2 | 3 | import 'io.dart' as io; 4 | 5 | /// [path] can be either a [`String`], a [`Uri`], or a [`FileSystemEntity`]. 6 | String resolvePath(dynamic pathLike) { 7 | if (pathLike is String) { 8 | return pathLike; 9 | } else if (pathLike is Uri) { 10 | return pathLike.toFilePath(); 11 | } else if (pathLike is io.FileSystemEntity) { 12 | return pathLike.path; 13 | } else { 14 | throw ArgumentError.value(pathLike, 'path', 'Invalid path type'); 15 | } 16 | } 17 | 18 | List concatBytes(List a, List b) { 19 | final result = List.filled(a.length + b.length, 0, growable: false); 20 | result.setRange(0, a.length, a); 21 | result.setRange(a.length, result.length, b); 22 | return result; 23 | } 24 | 25 | bool compareBytes(List? a, List? b) { 26 | if (a == null || b == null) return a == b; 27 | if (a.length != b.length) return false; 28 | return const ListEquality().equals(a, b); 29 | } 30 | 31 | /// Tells if the specified file mode represents a write mode. 32 | bool isWriteMode(io.FileMode mode) => 33 | mode == io.FileMode.write || 34 | mode == io.FileMode.append || 35 | mode == io.FileMode.writeOnly || 36 | mode == io.FileMode.writeOnlyAppend; 37 | 38 | /// Tells whether the given string is empty. 39 | bool isEmpty(String str) => str.isEmpty; 40 | 41 | // /// Returns the node ultimately referred to by [link]. This will resolve 42 | // /// the link references (following chains of links as necessary) and return 43 | // /// the node at the end of the link chain. 44 | // /// 45 | // /// If a loop in the link chain is found, this will throw a 46 | // /// [FileSystemException], calling [path] to generate the path. 47 | // /// 48 | // /// If [ledger] is specified, the resolved path to the terminal node will be 49 | // /// appended to the ledger (or overwritten in the ledger if a link target 50 | // /// specified an absolute path). The path will not be normalized, meaning 51 | // /// `..` and `.` path segments may be present. 52 | // /// 53 | // /// If [tailVisitor] is specified, it will be invoked for the tail element of 54 | // /// the last link in the symbolic link chain, and its return value will be the 55 | // /// return value of this method (thus allowing callers to create the entity 56 | // /// at the end of the chain on demand). 57 | // Node resolveLinks( 58 | // LinkNode link, 59 | // PathGenerator path, { 60 | // List? ledger, 61 | // Node? Function(DirectoryNode parent, String childName, Node? child)? 62 | // tailVisitor, 63 | // }) { 64 | // // Record a breadcrumb trail to guard against symlink loops. 65 | // var breadcrumbs = {}; 66 | 67 | // Node node = link; 68 | // while (isLink(node)) { 69 | // link = node as LinkNode; 70 | // if (!breadcrumbs.add(link)) { 71 | // throw common.tooManyLevelsOfSymbolicLinks(path() as String); 72 | // } 73 | // if (ledger != null) { 74 | // if (link.fs.path.isAbsolute(link.target)) { 75 | // ledger.clear(); 76 | // } else if (ledger.isNotEmpty) { 77 | // ledger.removeLast(); 78 | // } 79 | // ledger.addAll(link.target.split(link.fs.path.separator)); 80 | // } 81 | // node = link.getReferent( 82 | // tailVisitor: (DirectoryNode parent, String childName, Node? child) { 83 | // if (tailVisitor != null && !isLink(child)) { 84 | // // Only invoke [tailListener] on the final resolution pass. 85 | // child = tailVisitor(parent, childName, child); 86 | // } 87 | // return child; 88 | // }, 89 | // ); 90 | // } 91 | 92 | // return node; 93 | // } 94 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: sqlite_fs 2 | description: pkg:file file system backed by pkg:sqlite3 3 | publish_to: 'none' 4 | version: 0.1.0 5 | 6 | environment: 7 | sdk: ^3.7.0 8 | 9 | dependencies: 10 | file: ^7.0.1 11 | sqlite3: ^2.7.5 12 | path: ^1.9.1 13 | collection: ^1.19.1 14 | 15 | dev_dependencies: 16 | flutter_lints: ^5.0.0 17 | file_testing: ^3.0.2 18 | test: ^1.25.15 19 | -------------------------------------------------------------------------------- /test/example.dart: -------------------------------------------------------------------------------- 1 | import 'package:file/file.dart'; 2 | import 'package:sqlite3/sqlite3.dart'; 3 | import 'package:sqlite_fs/sqlite_fs.dart'; 4 | 5 | void main() { 6 | final fs = SqliteFileSystem.fromDb(sqlite3.openInMemory()); 7 | 8 | final dir = fs.directory('temp'); 9 | if (dir.existsSync()) { 10 | dir.deleteSync(recursive: true); 11 | } 12 | dir.createSync(recursive: true); 13 | 14 | _addFile(fs, dir, 'file1.txt'); 15 | _addFile(fs, dir, 'file2.txt'); 16 | 17 | _addDirectory(fs, dir, 'dir1'); 18 | _addDirectory(fs, dir, 'dir2'); 19 | 20 | final files = dir.listSync(); 21 | final paths = files.map((file) => file.path).toList(); 22 | print('paths: $paths'); 23 | 24 | dir.deleteSync(recursive: true); 25 | fs.db.close(); 26 | } 27 | 28 | File _addFile(FileSystem fs, Directory dir, String path) { 29 | final file = fs.file(fs.path.join(dir.path, path)); 30 | file.writeAsStringSync('Hello, world!'); 31 | return file; 32 | } 33 | 34 | Directory _addDirectory(FileSystem fs, Directory dir, String path) { 35 | final directory = fs.directory(fs.path.join(dir.path, path)); 36 | directory.createSync(recursive: true); 37 | return directory; 38 | } 39 | -------------------------------------------------------------------------------- /test/fs_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:file/file.dart'; 2 | import 'package:file_testing/file_testing.dart'; 3 | import 'package:sqlite3/sqlite3.dart'; 4 | import 'package:sqlite_fs/sqlite_fs.dart'; 5 | import 'package:test/test.dart'; 6 | 7 | void main() { 8 | late FileSystem fs; 9 | late DB db; 10 | 11 | setUp(() { 12 | db = DB(sqlite3.openInMemory()); 13 | fs = SqliteFileSystem(db); 14 | fs.file('/foo').createSync(recursive: true); 15 | fs.file('/path/to/file').createSync(recursive: true); 16 | fs.directory('/path/to/directory').createSync(recursive: true); 17 | }); 18 | 19 | tearDown(() { 20 | fs.file('/foo').deleteSync(); 21 | fs.file('/path/to/file').deleteSync(); 22 | fs.directory('/path/to/directory').deleteSync(); 23 | db.close(); 24 | }); 25 | 26 | test('some test', () { 27 | expectFileSystemException(ErrorCodes.ENOENT, () { 28 | fs.directory('').resolveSymbolicLinksSync(); 29 | }); 30 | expect(fs.file('/path/to/file'), isFile); 31 | expect(fs.directory('/path/to/directory'), isDirectory); 32 | expect(fs.file('/foo'), exists); 33 | }); 34 | } 35 | --------------------------------------------------------------------------------