diff --git a/packages/sqlite3_vec/.gitignore b/packages/sqlite3_vec/.gitignore
new file mode 100644
index 00000000..ea810a52
--- /dev/null
+++ b/packages/sqlite3_vec/.gitignore
@@ -0,0 +1,31 @@
+# Miscellaneous
+*.class
+*.log
+*.pyc
+*.swp
+.DS_Store
+.atom/
+.build/
+.buildlog/
+.history
+.svn/
+.swiftpm/
+migrate_working_dir/
+
+# IntelliJ related
+*.iml
+*.ipr
+*.iws
+.idea/
+
+# The .vscode folder contains launch configuration and tasks you configure in
+# VS Code which you may wish to be included in version control, so this line
+# is commented out by default.
+#.vscode/
+
+# Flutter/Dart/Pub related
+# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
+/pubspec.lock
+**/doc/api/
+.dart_tool/
+build/
diff --git a/packages/sqlite3_vec/.metadata b/packages/sqlite3_vec/.metadata
new file mode 100644
index 00000000..2ab4d1aa
--- /dev/null
+++ b/packages/sqlite3_vec/.metadata
@@ -0,0 +1,33 @@
+# This file tracks properties of this Flutter project.
+# Used by Flutter tool to assess capabilities and perform upgrades etc.
+#
+# This file should be version controlled and should not be manually edited.
+
+version:
+ revision: "17025dd88227cd9532c33fa78f5250d548d87e9a"
+ channel: "stable"
+
+project_type: plugin
+
+# Tracks metadata for the flutter migrate command
+migration:
+ platforms:
+ - platform: root
+ create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
+ base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
+ - platform: android
+ create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
+ base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
+ - platform: linux
+ create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
+ base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
+
+ # User provided section
+
+ # List of Local paths (relative to this file) that should be
+ # ignored by the migrate tool.
+ #
+ # Files that are not part of the templates will be ignored by default.
+ unmanaged_files:
+ - 'lib/main.dart'
+ - 'ios/Runner.xcodeproj/project.pbxproj'
diff --git a/packages/sqlite3_vec/CHANGELOG.md b/packages/sqlite3_vec/CHANGELOG.md
new file mode 100644
index 00000000..41cc7d81
--- /dev/null
+++ b/packages/sqlite3_vec/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 0.0.1
+
+* TODO: Describe initial release.
diff --git a/packages/sqlite3_vec/LICENSE b/packages/sqlite3_vec/LICENSE
new file mode 100644
index 00000000..261eeb9e
--- /dev/null
+++ b/packages/sqlite3_vec/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/sqlite3_vec/README.md b/packages/sqlite3_vec/README.md
new file mode 100644
index 00000000..0d66fd6a
--- /dev/null
+++ b/packages/sqlite3_vec/README.md
@@ -0,0 +1,15 @@
+# sqlite3_vec
+
+A new Flutter plugin project.
+
+## Getting Started
+
+This project is a starting point for a Flutter
+[plug-in package](https://flutter.dev/to/develop-plugins),
+a specialized package that includes platform-specific implementation code for
+Android and/or iOS.
+
+For help getting started with Flutter development, view the
+[online documentation](https://docs.flutter.dev), which offers tutorials,
+samples, guidance on mobile development, and a full API reference.
+
diff --git a/packages/sqlite3_vec/analysis_options.yaml b/packages/sqlite3_vec/analysis_options.yaml
new file mode 100644
index 00000000..4d829f60
--- /dev/null
+++ b/packages/sqlite3_vec/analysis_options.yaml
@@ -0,0 +1,35 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lint/package.yaml
+# Uncomment the following section to specify additional rules.
+
+linter:
+ rules:
+ - unawaited_futures
+ - discarded_futures
+ - collection_methods_unrelated_type
+
+analyzer:
+ plugins:
+ - custom_lint
+ exclude:
+ - "**.g.dart"
+ - "**.swagger.dart"
+ - "**.freezed.dart"
+ - "**.chopper.dart"
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/packages/sqlite3_vec/android/.gitignore b/packages/sqlite3_vec/android/.gitignore
new file mode 100644
index 00000000..55afd919
--- /dev/null
+++ b/packages/sqlite3_vec/android/.gitignore
@@ -0,0 +1,13 @@
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
+/local.properties
+GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/to/reference-keystore
+key.properties
+**/*.keystore
+**/*.jks
diff --git a/packages/sqlite3_vec/android/CMakeLists.txt b/packages/sqlite3_vec/android/CMakeLists.txt
new file mode 100644
index 00000000..676e27a7
--- /dev/null
+++ b/packages/sqlite3_vec/android/CMakeLists.txt
@@ -0,0 +1,77 @@
+cmake_minimum_required(VERSION 3.10)
+
+# Set the project name
+project(sqlite_vec)
+
+# Set default compiler if not provided
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER gcc)
+endif()
+
+# Configure Android specific settings
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+
+include(FetchContent)
+if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
+ # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when
+ # the default is used, so override it to the recommended behavior.
+ # We can't really ask users to use a cmake that recent, so there's this if here.
+ FetchContent_Declare(
+ sqlite3
+ URL https://sqlite.org/2024/sqlite-autoconf-3470200.tar.gz
+ DOWNLOAD_EXTRACT_TIMESTAMP NEW
+ )
+
+ FetchContent_Declare(
+ vec0
+ URL https://github.com/asg017/sqlite-vec/archive/refs/tags/v0.1.7-alpha.2.tar.gz
+ DOWNLOAD_EXTRACT_TIMESTAMP NEW
+ )
+else()
+ FetchContent_Declare(
+ sqlite3
+ URL https://sqlite.org/2024/sqlite-autoconf-3470200.tar.gz
+ )
+
+ FetchContent_Declare(
+ vec0
+ URL https://github.com/asg017/sqlite-vec/archive/refs/tags/v0.1.7-alpha.2.tar.gz
+ )
+endif()
+
+FetchContent_MakeAvailable(sqlite3)
+FetchContent_MakeAvailable(vec0)
+
+add_custom_command(
+ OUTPUT ${vec0_SOURCE_DIR}/sqlite-vec.h
+ COMMAND make sqlite-vec.h
+ WORKING_DIRECTORY ${vec0_SOURCE_DIR}
+ COMMENT "Building sqlite-vec.h with make"
+)
+
+add_custom_target(generate_vec_header
+ DEPENDS ${vec0_SOURCE_DIR}/sqlite-vec.h
+)
+
+add_library(vec0
+ SHARED
+ ${vec0_SOURCE_DIR}/sqlite-vec.c
+)
+
+add_dependencies(vec0 generate_vec_header)
+
+# Include directories
+target_include_directories(vec0
+ PRIVATE
+ ${vec0_SOURCE_DIR}
+ ${sqlite3_SOURCE_DIR}
+)
+
+# Set compile options
+target_compile_options(vec0
+ PRIVATE
+ -Wall
+ -Wextra
+ -O3
+)
diff --git a/packages/sqlite3_vec/android/build.gradle b/packages/sqlite3_vec/android/build.gradle
new file mode 100644
index 00000000..b427d0d0
--- /dev/null
+++ b/packages/sqlite3_vec/android/build.gradle
@@ -0,0 +1,55 @@
+group = "me.movenext.sqlite3_vec"
+version = "1.0-SNAPSHOT"
+
+buildscript {
+ ext.kotlin_version = "1.8.22"
+ repositories {
+ google()
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath("com.android.tools.build:gradle:8.1.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+apply plugin: "com.android.library"
+apply plugin: "kotlin-android"
+
+android {
+ namespace = "me.movenext.sqlite3_vec"
+
+ compileSdk = 35
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_11
+ }
+
+ sourceSets {
+ main.java.srcDirs += "src/main/kotlin"
+ test.java.srcDirs += "src/test/kotlin"
+ }
+
+ defaultConfig {
+ minSdk = 21
+ }
+
+ externalNativeBuild {
+ cmake {
+ path "CMakeLists.txt"
+ }
+ }
+}
diff --git a/packages/sqlite3_vec/android/settings.gradle b/packages/sqlite3_vec/android/settings.gradle
new file mode 100644
index 00000000..ff6786e8
--- /dev/null
+++ b/packages/sqlite3_vec/android/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'sqlite3_vec'
diff --git a/packages/sqlite3_vec/android/src/main/AndroidManifest.xml b/packages/sqlite3_vec/android/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..b3d55606
--- /dev/null
+++ b/packages/sqlite3_vec/android/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@
+
+
diff --git a/packages/sqlite3_vec/android/src/main/kotlin/me/movenext/sqlite3_vec/Sqlite3VecPlugin.kt b/packages/sqlite3_vec/android/src/main/kotlin/me/movenext/sqlite3_vec/Sqlite3VecPlugin.kt
new file mode 100644
index 00000000..61c608bc
--- /dev/null
+++ b/packages/sqlite3_vec/android/src/main/kotlin/me/movenext/sqlite3_vec/Sqlite3VecPlugin.kt
@@ -0,0 +1,16 @@
+package me.movenext.sqlite3_vec
+
+import androidx.annotation.NonNull
+
+import io.flutter.embedding.engine.plugins.FlutterPlugin
+
+/** Sqlite3VecPlugin */
+class Sqlite3VecPlugin: FlutterPlugin {
+ override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
+
+ }
+
+ override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
+
+ }
+}
diff --git a/packages/sqlite3_vec/example/.flutter-plugins b/packages/sqlite3_vec/example/.flutter-plugins
new file mode 100644
index 00000000..f7e79017
--- /dev/null
+++ b/packages/sqlite3_vec/example/.flutter-plugins
@@ -0,0 +1,4 @@
+# This is a generated file; do not edit or check into version control.
+integration_test=/home/fafre/development/flutter/packages/integration_test/
+sqlite3_flutter_libs=/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/
+sqlite3_vec=/home/fafre/development/repos/lensai/packages/sqlite3_vec/
diff --git a/packages/sqlite3_vec/example/.flutter-plugins-dependencies b/packages/sqlite3_vec/example/.flutter-plugins-dependencies
new file mode 100644
index 00000000..6898a0c9
--- /dev/null
+++ b/packages/sqlite3_vec/example/.flutter-plugins-dependencies
@@ -0,0 +1 @@
+{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"/home/fafre/development/flutter/packages/integration_test/","native_build":true,"dependencies":[]},{"name":"sqlite3_flutter_libs","path":"/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"integration_test","path":"/home/fafre/development/flutter/packages/integration_test/","native_build":true,"dependencies":[]},{"name":"sqlite3_flutter_libs","path":"/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/","native_build":true,"dependencies":[]},{"name":"sqlite3_vec","path":"/home/fafre/development/repos/lensai/packages/sqlite3_vec/","native_build":true,"dependencies":[]}],"macos":[{"name":"sqlite3_flutter_libs","path":"/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"sqlite3_flutter_libs","path":"/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/","native_build":true,"dependencies":[]},{"name":"sqlite3_vec","path":"/home/fafre/development/repos/lensai/packages/sqlite3_vec/","native_build":true,"dependencies":[]}],"windows":[{"name":"sqlite3_flutter_libs","path":"/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/","native_build":true,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"sqlite3_flutter_libs","dependencies":[]},{"name":"sqlite3_vec","dependencies":[]}],"date_created":"2025-01-17 14:26:43.439781","version":"3.27.1","swift_package_manager_enabled":false}
\ No newline at end of file
diff --git a/packages/sqlite3_vec/example/README.md b/packages/sqlite3_vec/example/README.md
new file mode 100644
index 00000000..be857fb2
--- /dev/null
+++ b/packages/sqlite3_vec/example/README.md
@@ -0,0 +1,16 @@
+# sqlite3_vec_example
+
+Demonstrates how to use the sqlite3_vec plugin.
+
+## Getting Started
+
+This project is a starting point for a Flutter application.
+
+A few resources to get you started if this is your first Flutter project:
+
+- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
+- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
+
+For help getting started with Flutter development, view the
+[online documentation](https://docs.flutter.dev/), which offers tutorials,
+samples, guidance on mobile development, and a full API reference.
diff --git a/packages/sqlite3_vec/example/analysis_options.yaml b/packages/sqlite3_vec/example/analysis_options.yaml
new file mode 100644
index 00000000..0d290213
--- /dev/null
+++ b/packages/sqlite3_vec/example/analysis_options.yaml
@@ -0,0 +1,28 @@
+# This file configures the analyzer, which statically analyzes Dart code to
+# check for errors, warnings, and lints.
+#
+# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
+# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
+# invoked from the command line by running `flutter analyze`.
+
+# The following line activates a set of recommended lints for Flutter apps,
+# packages, and plugins designed to encourage good coding practices.
+include: package:flutter_lints/flutter.yaml
+
+linter:
+ # The lint rules applied to this project can be customized in the
+ # section below to disable rules from the `package:flutter_lints/flutter.yaml`
+ # included above or to enable additional rules. A list of all available lints
+ # and their documentation is published at https://dart.dev/lints.
+ #
+ # Instead of disabling a lint rule for the entire project in the
+ # section below, it can also be suppressed for a single line of code
+ # or a specific dart file by using the `// ignore: name_of_lint` and
+ # `// ignore_for_file: name_of_lint` syntax on the line or in the file
+ # producing the lint.
+ rules:
+ # avoid_print: false # Uncomment to disable the `avoid_print` rule
+ # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
+
+# Additional information about this file can be found at
+# https://dart.dev/guides/language/analysis-options
diff --git a/packages/sqlite3_vec/example/android/app/build.gradle b/packages/sqlite3_vec/example/android/app/build.gradle
new file mode 100644
index 00000000..483a2066
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/build.gradle
@@ -0,0 +1,44 @@
+plugins {
+ id "com.android.application"
+ id "kotlin-android"
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
+ id "dev.flutter.flutter-gradle-plugin"
+}
+
+android {
+ namespace = "me.movenext.sqlite3_vec_example"
+ compileSdk = flutter.compileSdkVersion
+ ndkVersion = flutter.ndkVersion
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_1_8
+ }
+
+ defaultConfig {
+ // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
+ applicationId = "me.movenext.sqlite3_vec_example"
+ // You can update the following values to match your application needs.
+ // For more information, see: https://flutter.dev/to/review-gradle-config.
+ minSdk = flutter.minSdkVersion
+ targetSdk = flutter.targetSdkVersion
+ versionCode = flutter.versionCode
+ versionName = flutter.versionName
+ }
+
+ buildTypes {
+ release {
+ // TODO: Add your own signing config for the release build.
+ // Signing with the debug keys for now, so `flutter run --release` works.
+ signingConfig = signingConfigs.debug
+ }
+ }
+}
+
+flutter {
+ source = "../.."
+}
diff --git a/packages/sqlite3_vec/example/android/app/src/debug/AndroidManifest.xml b/packages/sqlite3_vec/example/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 00000000..399f6981
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/app/src/main/AndroidManifest.xml b/packages/sqlite3_vec/example/android/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..c4163281
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/packages/sqlite3_vec/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
new file mode 100644
index 00000000..903dd3b8
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
@@ -0,0 +1,34 @@
+package io.flutter.plugins;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import io.flutter.Log;
+
+import io.flutter.embedding.engine.FlutterEngine;
+
+/**
+ * Generated file. Do not edit.
+ * This file is generated by the Flutter tool based on the
+ * plugins that support the Android platform.
+ */
+@Keep
+public final class GeneratedPluginRegistrant {
+ private static final String TAG = "GeneratedPluginRegistrant";
+ public static void registerWith(@NonNull FlutterEngine flutterEngine) {
+ try {
+ flutterEngine.getPlugins().add(new dev.flutter.plugins.integration_test.IntegrationTestPlugin());
+ } catch (Exception e) {
+ Log.e(TAG, "Error registering plugin integration_test, dev.flutter.plugins.integration_test.IntegrationTestPlugin", e);
+ }
+ try {
+ flutterEngine.getPlugins().add(new eu.simonbinder.sqlite3_flutter_libs.Sqlite3FlutterLibsPlugin());
+ } catch (Exception e) {
+ Log.e(TAG, "Error registering plugin sqlite3_flutter_libs, eu.simonbinder.sqlite3_flutter_libs.Sqlite3FlutterLibsPlugin", e);
+ }
+ try {
+ flutterEngine.getPlugins().add(new me.movenext.sqlite3_vec.Sqlite3VecPlugin());
+ } catch (Exception e) {
+ Log.e(TAG, "Error registering plugin sqlite3_vec, me.movenext.sqlite3_vec.Sqlite3VecPlugin", e);
+ }
+ }
+}
diff --git a/packages/sqlite3_vec/example/android/app/src/main/kotlin/me/movenext/sqlite3_vec_example/MainActivity.kt b/packages/sqlite3_vec/example/android/app/src/main/kotlin/me/movenext/sqlite3_vec_example/MainActivity.kt
new file mode 100644
index 00000000..a551b6cb
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/kotlin/me/movenext/sqlite3_vec_example/MainActivity.kt
@@ -0,0 +1,5 @@
+package me.movenext.sqlite3_vec_example
+
+import io.flutter.embedding.android.FlutterActivity
+
+class MainActivity: FlutterActivity()
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/drawable-v21/launch_background.xml b/packages/sqlite3_vec/example/android/app/src/main/res/drawable-v21/launch_background.xml
new file mode 100644
index 00000000..f74085f3
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/drawable/launch_background.xml b/packages/sqlite3_vec/example/android/app/src/main/res/drawable/launch_background.xml
new file mode 100644
index 00000000..304732f8
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/res/drawable/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 00000000..db77bb4b
Binary files /dev/null and b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 00000000..17987b79
Binary files /dev/null and b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 00000000..09d43914
Binary files /dev/null and b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 00000000..d5f1c8d3
Binary files /dev/null and b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 00000000..4d6372ee
Binary files /dev/null and b/packages/sqlite3_vec/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/values-night/styles.xml b/packages/sqlite3_vec/example/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 00000000..06952be7
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/app/src/main/res/values/styles.xml b/packages/sqlite3_vec/example/android/app/src/main/res/values/styles.xml
new file mode 100644
index 00000000..cb1ef880
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/main/res/values/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/app/src/profile/AndroidManifest.xml b/packages/sqlite3_vec/example/android/app/src/profile/AndroidManifest.xml
new file mode 100644
index 00000000..399f6981
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/packages/sqlite3_vec/example/android/build.gradle b/packages/sqlite3_vec/example/android/build.gradle
new file mode 100644
index 00000000..d2ffbffa
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/build.gradle
@@ -0,0 +1,18 @@
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+rootProject.buildDir = "../build"
+subprojects {
+ project.buildDir = "${rootProject.buildDir}/${project.name}"
+}
+subprojects {
+ project.evaluationDependsOn(":app")
+}
+
+tasks.register("clean", Delete) {
+ delete rootProject.buildDir
+}
diff --git a/packages/sqlite3_vec/example/android/gradle.properties b/packages/sqlite3_vec/example/android/gradle.properties
new file mode 100644
index 00000000..25971708
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/gradle.properties
@@ -0,0 +1,3 @@
+org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/packages/sqlite3_vec/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/sqlite3_vec/example/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..7bb2df6b
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
diff --git a/packages/sqlite3_vec/example/android/local.properties b/packages/sqlite3_vec/example/android/local.properties
new file mode 100644
index 00000000..930db76c
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/local.properties
@@ -0,0 +1,2 @@
+sdk.dir=/home/fafre/Android/Sdk
+flutter.sdk=/home/fafre/development/flutter
\ No newline at end of file
diff --git a/packages/sqlite3_vec/example/android/settings.gradle b/packages/sqlite3_vec/example/android/settings.gradle
new file mode 100644
index 00000000..b9e43bd3
--- /dev/null
+++ b/packages/sqlite3_vec/example/android/settings.gradle
@@ -0,0 +1,25 @@
+pluginManagement {
+ def flutterSdkPath = {
+ def properties = new Properties()
+ file("local.properties").withInputStream { properties.load(it) }
+ def flutterSdkPath = properties.getProperty("flutter.sdk")
+ assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+ return flutterSdkPath
+ }()
+
+ includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
+
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
+plugins {
+ id "dev.flutter.flutter-plugin-loader" version "1.0.0"
+ id "com.android.application" version "8.1.0" apply false
+ id "org.jetbrains.kotlin.android" version "1.8.22" apply false
+}
+
+include ":app"
diff --git a/packages/sqlite3_vec/example/lib/main.dart b/packages/sqlite3_vec/example/lib/main.dart
new file mode 100644
index 00000000..0074841f
--- /dev/null
+++ b/packages/sqlite3_vec/example/lib/main.dart
@@ -0,0 +1,49 @@
+import 'package:flutter/material.dart';
+import 'package:sqlite3/sqlite3.dart';
+import 'package:sqlite3_vec/sqlite3_vec.dart';
+
+void main() async {
+ WidgetsFlutterBinding.ensureInitialized();
+
+ Sqlite3Vec.ensureExtensionLoaded();
+
+ final db = sqlite3.openInMemory();
+
+ runApp(MyApp(db: db));
+}
+
+class MyApp extends StatefulWidget {
+ const MyApp({super.key, required this.db});
+
+ final Database db;
+
+ @override
+ State createState() => _MyAppState();
+}
+
+class _MyAppState extends State {
+ @override
+ void dispose() {
+ widget.db.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final version = widget.db //
+ .select('SELECT vec_version() as version;')
+ .first['version'];
+ return MaterialApp(
+ home: Scaffold(
+ appBar: AppBar(
+ title: const Text('sqlite-vec'),
+ ),
+ body: Center(
+ child: Text(
+ 'version: $version',
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/packages/sqlite3_vec/example/linux/CMakeLists.txt b/packages/sqlite3_vec/example/linux/CMakeLists.txt
new file mode 100644
index 00000000..a0fedf05
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/CMakeLists.txt
@@ -0,0 +1,130 @@
+# Project-level configuration.
+cmake_minimum_required(VERSION 3.13)
+project(runner LANGUAGES CXX)
+
+# The name of the executable created for the application. Change this to change
+# the on-disk name of your application.
+set(BINARY_NAME "sqlite3_vec_example")
+# The unique GTK application identifier for this application. See:
+# https://wiki.gnome.org/HowDoI/ChooseApplicationID
+set(APPLICATION_ID "me.movenext.sqlite3_vec")
+
+# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
+# versions of CMake.
+cmake_policy(SET CMP0063 NEW)
+
+# Load bundled libraries from the lib/ directory relative to the binary.
+set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
+
+# Root filesystem for cross-building.
+if(FLUTTER_TARGET_PLATFORM_SYSROOT)
+ set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
+ set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+endif()
+
+# Define build configuration options.
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE
+ STRING "Flutter build mode" FORCE)
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
+ "Debug" "Profile" "Release")
+endif()
+
+# Compilation settings that should be applied to most targets.
+#
+# Be cautious about adding new options here, as plugins use this function by
+# default. In most cases, you should add new options to specific targets instead
+# of modifying this function.
+function(APPLY_STANDARD_SETTINGS TARGET)
+ target_compile_features(${TARGET} PUBLIC cxx_std_14)
+ target_compile_options(${TARGET} PRIVATE -Wall -Werror)
+ target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
+ target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
+endfunction()
+
+# Flutter library and tool build rules.
+set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
+add_subdirectory(${FLUTTER_MANAGED_DIR})
+
+# System-level dependencies.
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
+
+# Application build; see runner/CMakeLists.txt.
+add_subdirectory("runner")
+
+# Run the Flutter tool portions of the build. This must not be removed.
+add_dependencies(${BINARY_NAME} flutter_assemble)
+
+# Only the install-generated bundle's copy of the executable will launch
+# correctly, since the resources must in the right relative locations. To avoid
+# people trying to run the unbundled copy, put it in a subdirectory instead of
+# the default top-level location.
+set_target_properties(${BINARY_NAME}
+ PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
+)
+
+# Enable the test target.
+set(include_sqlite3_vec_tests TRUE)
+
+# Generated plugin build rules, which manage building the plugins and adding
+# them to the application.
+include(flutter/generated_plugins.cmake)
+
+
+# === Installation ===
+# By default, "installing" just makes a relocatable bundle in the build
+# directory.
+set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
+endif()
+
+# Start with a clean build bundle directory every time.
+install(CODE "
+ file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
+ " COMPONENT Runtime)
+
+set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
+set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+
+install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
+ COMPONENT Runtime)
+
+install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
+ COMPONENT Runtime)
+
+install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+
+foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
+ install(FILES "${bundled_library}"
+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+endforeach(bundled_library)
+
+# Copy the native assets provided by the build.dart from all packages.
+set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
+install(DIRECTORY "${NATIVE_ASSETS_DIR}"
+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+
+# Fully re-copy the assets directory on each build to avoid having stale files
+# from a previous install.
+set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
+install(CODE "
+ file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
+ " COMPONENT Runtime)
+install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
+ DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
+
+# Install the AOT library on non-Debug builds only.
+if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+ install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+endif()
diff --git a/packages/sqlite3_vec/example/linux/flutter/CMakeLists.txt b/packages/sqlite3_vec/example/linux/flutter/CMakeLists.txt
new file mode 100644
index 00000000..d5bd0164
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/flutter/CMakeLists.txt
@@ -0,0 +1,88 @@
+# This file controls Flutter-level build steps. It should not be edited.
+cmake_minimum_required(VERSION 3.10)
+
+set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
+
+# Configuration provided via flutter tool.
+include(${EPHEMERAL_DIR}/generated_config.cmake)
+
+# TODO: Move the rest of this into files in ephemeral. See
+# https://github.com/flutter/flutter/issues/57146.
+
+# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
+# which isn't available in 3.10.
+function(list_prepend LIST_NAME PREFIX)
+ set(NEW_LIST "")
+ foreach(element ${${LIST_NAME}})
+ list(APPEND NEW_LIST "${PREFIX}${element}")
+ endforeach(element)
+ set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
+endfunction()
+
+# === Flutter Library ===
+# System-level dependencies.
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
+pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
+pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
+
+set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
+
+# Published to parent scope for install step.
+set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
+set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
+set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
+set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
+
+list(APPEND FLUTTER_LIBRARY_HEADERS
+ "fl_basic_message_channel.h"
+ "fl_binary_codec.h"
+ "fl_binary_messenger.h"
+ "fl_dart_project.h"
+ "fl_engine.h"
+ "fl_json_message_codec.h"
+ "fl_json_method_codec.h"
+ "fl_message_codec.h"
+ "fl_method_call.h"
+ "fl_method_channel.h"
+ "fl_method_codec.h"
+ "fl_method_response.h"
+ "fl_plugin_registrar.h"
+ "fl_plugin_registry.h"
+ "fl_standard_message_codec.h"
+ "fl_standard_method_codec.h"
+ "fl_string_codec.h"
+ "fl_value.h"
+ "fl_view.h"
+ "flutter_linux.h"
+)
+list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
+add_library(flutter INTERFACE)
+target_include_directories(flutter INTERFACE
+ "${EPHEMERAL_DIR}"
+)
+target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
+target_link_libraries(flutter INTERFACE
+ PkgConfig::GTK
+ PkgConfig::GLIB
+ PkgConfig::GIO
+)
+add_dependencies(flutter flutter_assemble)
+
+# === Flutter tool backend ===
+# _phony_ is a non-existent file to force this command to run every time,
+# since currently there's no way to get a full input/output list from the
+# flutter tool.
+add_custom_command(
+ OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
+ ${CMAKE_CURRENT_BINARY_DIR}/_phony_
+ COMMAND ${CMAKE_COMMAND} -E env
+ ${FLUTTER_TOOL_ENVIRONMENT}
+ "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
+ ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
+ VERBATIM
+)
+add_custom_target(flutter_assemble DEPENDS
+ "${FLUTTER_LIBRARY}"
+ ${FLUTTER_LIBRARY_HEADERS}
+)
diff --git a/packages/sqlite3_vec/example/linux/flutter/ephemeral/.plugin_symlinks/sqlite3_flutter_libs b/packages/sqlite3_vec/example/linux/flutter/ephemeral/.plugin_symlinks/sqlite3_flutter_libs
new file mode 120000
index 00000000..5df7b5a0
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/flutter/ephemeral/.plugin_symlinks/sqlite3_flutter_libs
@@ -0,0 +1 @@
+/home/fafre/.pub-cache/hosted/pub.dev/sqlite3_flutter_libs-0.5.28/
\ No newline at end of file
diff --git a/packages/sqlite3_vec/example/linux/flutter/ephemeral/.plugin_symlinks/sqlite3_vec b/packages/sqlite3_vec/example/linux/flutter/ephemeral/.plugin_symlinks/sqlite3_vec
new file mode 120000
index 00000000..e2d791c8
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/flutter/ephemeral/.plugin_symlinks/sqlite3_vec
@@ -0,0 +1 @@
+/home/fafre/development/repos/lensai/packages/sqlite3_vec/
\ No newline at end of file
diff --git a/packages/sqlite3_vec/example/linux/flutter/generated_plugin_registrant.cc b/packages/sqlite3_vec/example/linux/flutter/generated_plugin_registrant.cc
new file mode 100644
index 00000000..3f44d03f
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/flutter/generated_plugin_registrant.cc
@@ -0,0 +1,19 @@
+//
+// Generated file. Do not edit.
+//
+
+// clang-format off
+
+#include "generated_plugin_registrant.h"
+
+#include
+#include
+
+void fl_register_plugins(FlPluginRegistry* registry) {
+ g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
+ fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
+ sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
+ g_autoptr(FlPluginRegistrar) sqlite3_vec_registrar =
+ fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3VecPlugin");
+ sqlite3_vec_plugin_register_with_registrar(sqlite3_vec_registrar);
+}
diff --git a/packages/sqlite3_vec/example/linux/flutter/generated_plugin_registrant.h b/packages/sqlite3_vec/example/linux/flutter/generated_plugin_registrant.h
new file mode 100644
index 00000000..e0f0a47b
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/flutter/generated_plugin_registrant.h
@@ -0,0 +1,15 @@
+//
+// Generated file. Do not edit.
+//
+
+// clang-format off
+
+#ifndef GENERATED_PLUGIN_REGISTRANT_
+#define GENERATED_PLUGIN_REGISTRANT_
+
+#include
+
+// Registers Flutter plugins.
+void fl_register_plugins(FlPluginRegistry* registry);
+
+#endif // GENERATED_PLUGIN_REGISTRANT_
diff --git a/packages/sqlite3_vec/example/linux/flutter/generated_plugins.cmake b/packages/sqlite3_vec/example/linux/flutter/generated_plugins.cmake
new file mode 100644
index 00000000..db36e839
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/flutter/generated_plugins.cmake
@@ -0,0 +1,25 @@
+#
+# Generated file, do not edit.
+#
+
+list(APPEND FLUTTER_PLUGIN_LIST
+ sqlite3_flutter_libs
+ sqlite3_vec
+)
+
+list(APPEND FLUTTER_FFI_PLUGIN_LIST
+)
+
+set(PLUGIN_BUNDLED_LIBRARIES)
+
+foreach(plugin ${FLUTTER_PLUGIN_LIST})
+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
+ target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
+endforeach(plugin)
+
+foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
+endforeach(ffi_plugin)
diff --git a/packages/sqlite3_vec/example/linux/runner/CMakeLists.txt b/packages/sqlite3_vec/example/linux/runner/CMakeLists.txt
new file mode 100644
index 00000000..e97dabc7
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/runner/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.13)
+project(runner LANGUAGES CXX)
+
+# Define the application target. To change its name, change BINARY_NAME in the
+# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
+# work.
+#
+# Any new source files that you add to the application should be added here.
+add_executable(${BINARY_NAME}
+ "main.cc"
+ "my_application.cc"
+ "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
+)
+
+# Apply the standard set of build settings. This can be removed for applications
+# that need different build settings.
+apply_standard_settings(${BINARY_NAME})
+
+# Add preprocessor definitions for the application ID.
+add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
+
+# Add dependency libraries. Add any application-specific dependencies here.
+target_link_libraries(${BINARY_NAME} PRIVATE flutter)
+target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
+
+target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
diff --git a/packages/sqlite3_vec/example/linux/runner/main.cc b/packages/sqlite3_vec/example/linux/runner/main.cc
new file mode 100644
index 00000000..e7c5c543
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/runner/main.cc
@@ -0,0 +1,6 @@
+#include "my_application.h"
+
+int main(int argc, char** argv) {
+ g_autoptr(MyApplication) app = my_application_new();
+ return g_application_run(G_APPLICATION(app), argc, argv);
+}
diff --git a/packages/sqlite3_vec/example/linux/runner/my_application.cc b/packages/sqlite3_vec/example/linux/runner/my_application.cc
new file mode 100644
index 00000000..c5ff4301
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/runner/my_application.cc
@@ -0,0 +1,130 @@
+#include "my_application.h"
+
+#include
+#ifdef GDK_WINDOWING_X11
+#include
+#endif
+
+#include "flutter/generated_plugin_registrant.h"
+
+struct _MyApplication {
+ GtkApplication parent_instance;
+ char** dart_entrypoint_arguments;
+};
+
+G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
+
+// Implements GApplication::activate.
+static void my_application_activate(GApplication* application) {
+ MyApplication* self = MY_APPLICATION(application);
+ GtkWindow* window =
+ GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
+
+ // Use a header bar when running in GNOME as this is the common style used
+ // by applications and is the setup most users will be using (e.g. Ubuntu
+ // desktop).
+ // If running on X and not using GNOME then just use a traditional title bar
+ // in case the window manager does more exotic layout, e.g. tiling.
+ // If running on Wayland assume the header bar will work (may need changing
+ // if future cases occur).
+ gboolean use_header_bar = TRUE;
+#ifdef GDK_WINDOWING_X11
+ GdkScreen* screen = gtk_window_get_screen(window);
+ if (GDK_IS_X11_SCREEN(screen)) {
+ const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
+ if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
+ use_header_bar = FALSE;
+ }
+ }
+#endif
+ if (use_header_bar) {
+ GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
+ gtk_widget_show(GTK_WIDGET(header_bar));
+ gtk_header_bar_set_title(header_bar, "sqlite3_vec_example");
+ gtk_header_bar_set_show_close_button(header_bar, TRUE);
+ gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
+ } else {
+ gtk_window_set_title(window, "sqlite3_vec_example");
+ }
+
+ gtk_window_set_default_size(window, 1280, 720);
+ gtk_widget_show(GTK_WIDGET(window));
+
+ g_autoptr(FlDartProject) project = fl_dart_project_new();
+ fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
+
+ FlView* view = fl_view_new(project);
+ gtk_widget_show(GTK_WIDGET(view));
+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
+
+ fl_register_plugins(FL_PLUGIN_REGISTRY(view));
+
+ gtk_widget_grab_focus(GTK_WIDGET(view));
+}
+
+// Implements GApplication::local_command_line.
+static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
+ MyApplication* self = MY_APPLICATION(application);
+ // Strip out the first argument as it is the binary name.
+ self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
+
+ g_autoptr(GError) error = nullptr;
+ if (!g_application_register(application, nullptr, &error)) {
+ g_warning("Failed to register: %s", error->message);
+ *exit_status = 1;
+ return TRUE;
+ }
+
+ g_application_activate(application);
+ *exit_status = 0;
+
+ return TRUE;
+}
+
+// Implements GApplication::startup.
+static void my_application_startup(GApplication* application) {
+ //MyApplication* self = MY_APPLICATION(object);
+
+ // Perform any actions required at application startup.
+
+ G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
+}
+
+// Implements GApplication::shutdown.
+static void my_application_shutdown(GApplication* application) {
+ //MyApplication* self = MY_APPLICATION(object);
+
+ // Perform any actions required at application shutdown.
+
+ G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
+}
+
+// Implements GObject::dispose.
+static void my_application_dispose(GObject* object) {
+ MyApplication* self = MY_APPLICATION(object);
+ g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
+ G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
+}
+
+static void my_application_class_init(MyApplicationClass* klass) {
+ G_APPLICATION_CLASS(klass)->activate = my_application_activate;
+ G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
+ G_APPLICATION_CLASS(klass)->startup = my_application_startup;
+ G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
+ G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
+}
+
+static void my_application_init(MyApplication* self) {}
+
+MyApplication* my_application_new() {
+ // Set the program name to the application ID, which helps various systems
+ // like GTK and desktop environments map this running application to its
+ // corresponding .desktop file. This ensures better integration by allowing
+ // the application to be recognized beyond its binary name.
+ g_set_prgname(APPLICATION_ID);
+
+ return MY_APPLICATION(g_object_new(my_application_get_type(),
+ "application-id", APPLICATION_ID,
+ "flags", G_APPLICATION_NON_UNIQUE,
+ nullptr));
+}
diff --git a/packages/sqlite3_vec/example/linux/runner/my_application.h b/packages/sqlite3_vec/example/linux/runner/my_application.h
new file mode 100644
index 00000000..72271d5e
--- /dev/null
+++ b/packages/sqlite3_vec/example/linux/runner/my_application.h
@@ -0,0 +1,18 @@
+#ifndef FLUTTER_MY_APPLICATION_H_
+#define FLUTTER_MY_APPLICATION_H_
+
+#include
+
+G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
+ GtkApplication)
+
+/**
+ * my_application_new:
+ *
+ * Creates a new Flutter-based application.
+ *
+ * Returns: a new #MyApplication.
+ */
+MyApplication* my_application_new();
+
+#endif // FLUTTER_MY_APPLICATION_H_
diff --git a/packages/sqlite3_vec/example/pubspec.yaml b/packages/sqlite3_vec/example/pubspec.yaml
new file mode 100644
index 00000000..6c466314
--- /dev/null
+++ b/packages/sqlite3_vec/example/pubspec.yaml
@@ -0,0 +1,87 @@
+name: sqlite3_vec_example
+description: "Demonstrates how to use the sqlite3_vec plugin."
+# The following line prevents the package from being accidentally published to
+# pub.dev using `flutter pub publish`. This is preferred for private packages.
+publish_to: 'none' # Remove this line if you wish to publish to pub.dev
+
+environment:
+ sdk: ^3.6.0
+
+# Dependencies specify other packages that your package needs in order to work.
+# To automatically upgrade your package dependencies to the latest versions
+# consider running `flutter pub upgrade --major-versions`. Alternatively,
+# dependencies can be manually updated by changing the version numbers below to
+# the latest version available on pub.dev. To see which dependencies have newer
+# versions available, run `flutter pub outdated`.
+dependencies:
+ flutter:
+ sdk: flutter
+
+ sqlite3_vec:
+ # When depending on this package from a real application you should use:
+ # sqlite3_vec: ^x.y.z
+ # See https://dart.dev/tools/pub/dependencies#version-constraints
+ # The example app is bundled with the plugin so we use a path dependency on
+ # the parent directory to use the current plugin's version.
+ path: ../
+
+ # The following adds the Cupertino Icons font to your application.
+ # Use with the CupertinoIcons class for iOS style icons.
+ cupertino_icons: ^1.0.8
+ sqlite3: ^2.6.0
+ sqlite3_flutter_libs: ^0.5.28
+
+dev_dependencies:
+ integration_test:
+ sdk: flutter
+ flutter_test:
+ sdk: flutter
+
+ # The "flutter_lints" package below contains a set of recommended lints to
+ # encourage good coding practices. The lint set provided by the package is
+ # activated in the `analysis_options.yaml` file located at the root of your
+ # package. See that file for information about deactivating specific lint
+ # rules and activating additional ones.
+ flutter_lints: ^5.0.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter packages.
+flutter:
+
+ # The following line ensures that the Material Icons font is
+ # included with your application, so that you can use the icons in
+ # the material Icons class.
+ uses-material-design: true
+
+ # To add assets to your application, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.dev/to/resolution-aware-images
+
+ # For details regarding adding assets from package dependencies, see
+ # https://flutter.dev/to/asset-from-package
+
+ # To add custom fonts to your application, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts from package dependencies,
+ # see https://flutter.dev/to/font-from-package
diff --git a/packages/sqlite3_vec/example/pubspec_overrides.yaml b/packages/sqlite3_vec/example/pubspec_overrides.yaml
new file mode 100644
index 00000000..2eaee419
--- /dev/null
+++ b/packages/sqlite3_vec/example/pubspec_overrides.yaml
@@ -0,0 +1,4 @@
+# melos_managed_dependency_overrides: sqlite3_vec
+dependency_overrides:
+ sqlite3_vec:
+ path: ..
diff --git a/packages/sqlite3_vec/lib/sqlite3_vec.dart b/packages/sqlite3_vec/lib/sqlite3_vec.dart
new file mode 100644
index 00000000..3b0cba84
--- /dev/null
+++ b/packages/sqlite3_vec/lib/sqlite3_vec.dart
@@ -0,0 +1,23 @@
+import 'dart:ffi';
+import 'dart:io';
+
+import 'package:sqlite3/sqlite3.dart';
+
+const String _libName = 'vec0';
+
+class Sqlite3Vec {
+ static void ensureExtensionLoaded() {
+ final libPath = switch (Platform.operatingSystem) {
+ //'macos' || 'ios' => DynamicLibrary.open('$_libName.framework/$_libName'),
+ 'android' || 'linux' => DynamicLibrary.open('lib$_libName.so'),
+ //'windows' => DynamicLibrary.open('$_libName.dll'),
+ _ => throw UnsupportedError(
+ 'Unsupported platform: ${Platform.operatingSystem}',
+ ),
+ };
+
+ sqlite3.ensureExtensionLoaded(
+ SqliteExtension.inLibrary(libPath, 'sqlite3_vec_init'),
+ );
+ }
+}
diff --git a/packages/sqlite3_vec/linux/CMakeLists.txt b/packages/sqlite3_vec/linux/CMakeLists.txt
new file mode 100644
index 00000000..6ba01d4c
--- /dev/null
+++ b/packages/sqlite3_vec/linux/CMakeLists.txt
@@ -0,0 +1,134 @@
+cmake_minimum_required(VERSION 3.10)
+
+# Project-level configuration.
+set(PROJECT_NAME "sqlite3_vec")
+project(${PROJECT_NAME} LANGUAGES CXX C)
+
+set(PLUGIN_NAME "sqlite3_vec_plugin")
+
+# Plugin sources
+list(APPEND PLUGIN_SOURCES
+ "sqlite3_vec_plugin.cc"
+)
+
+# Fetch SQLite and Vec libraries
+include(FetchContent)
+if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
+ FetchContent_Declare(
+ sqlite3
+ URL https://sqlite.org/2024/sqlite-autoconf-3470200.tar.gz
+ DOWNLOAD_EXTRACT_TIMESTAMP NEW
+ )
+ FetchContent_Declare(
+ vec0
+ URL https://github.com/asg017/sqlite-vec/archive/refs/tags/v0.1.7-alpha.2.tar.gz
+ DOWNLOAD_EXTRACT_TIMESTAMP NEW
+ )
+else()
+ FetchContent_Declare(
+ sqlite3
+ URL https://sqlite.org/2024/sqlite-autoconf-3470200.tar.gz
+ )
+ FetchContent_Declare(
+ vec0
+ URL https://github.com/asg017/sqlite-vec/archive/refs/tags/v0.1.7-alpha.2.tar.gz
+ )
+endif()
+
+FetchContent_MakeAvailable(sqlite3)
+FetchContent_MakeAvailable(vec0)
+
+# Generate Vec header
+add_custom_command(
+ OUTPUT ${vec0_SOURCE_DIR}/sqlite-vec.h
+ COMMAND make sqlite-vec.h
+ WORKING_DIRECTORY ${vec0_SOURCE_DIR}
+ COMMENT "Building sqlite-vec.h with make"
+)
+
+add_custom_target(generate_vec_header
+ DEPENDS ${vec0_SOURCE_DIR}/sqlite-vec.h
+)
+
+# Build Vec library
+add_library(vec0
+ SHARED
+ ${vec0_SOURCE_DIR}/sqlite-vec.c
+)
+
+add_dependencies(vec0 generate_vec_header)
+
+target_include_directories(vec0
+ PRIVATE
+ ${vec0_SOURCE_DIR}
+ ${sqlite3_SOURCE_DIR}
+)
+
+target_compile_options(vec0
+ PRIVATE
+ -Wall
+ -Wextra
+ -O3
+)
+
+# Plugin library
+add_library(${PLUGIN_NAME} SHARED
+ ${PLUGIN_SOURCES}
+)
+
+apply_standard_settings(${PLUGIN_NAME})
+set_target_properties(${PLUGIN_NAME} PROPERTIES
+ CXX_VISIBILITY_PRESET hidden)
+target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
+
+target_include_directories(${PLUGIN_NAME} INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}/include")
+target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
+target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
+target_link_libraries(${PLUGIN_NAME} PRIVATE vec0)
+
+# Bundle the vec0 library
+set(sqlite3_vec_bundled_libraries
+ "$"
+ PARENT_SCOPE
+)
+
+# Tests section remains unchanged
+if (${include_${PROJECT_NAME}_tests})
+if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
+message("Unit tests require CMake 3.11.0 or later")
+else()
+set(TEST_RUNNER "${PROJECT_NAME}_test")
+enable_testing()
+
+# Add the Google Test dependency.
+include(FetchContent)
+FetchContent_Declare(
+ googletest
+ URL https://github.com/google/googletest/archive/release-1.11.0.zip
+)
+# Prevent overriding the parent project's compiler/linker settings
+set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+# Disable install commands for gtest so it doesn't end up in the bundle.
+set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE)
+
+FetchContent_MakeAvailable(googletest)
+
+# The plugin's exported API is not very useful for unit testing, so build the
+# sources directly into the test binary rather than using the shared library.
+add_executable(${TEST_RUNNER}
+ test/sqlite3_vec_plugin_test.cc
+ ${PLUGIN_SOURCES}
+)
+apply_standard_settings(${TEST_RUNNER})
+target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
+target_link_libraries(${TEST_RUNNER} PRIVATE flutter)
+target_link_libraries(${TEST_RUNNER} PRIVATE PkgConfig::GTK)
+target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock)
+
+# Enable automatic test discovery.
+include(GoogleTest)
+gtest_discover_tests(${TEST_RUNNER})
+
+endif() # CMake version check
+endif() # include_${PROJECT_NAME}_tests
\ No newline at end of file
diff --git a/packages/sqlite3_vec/linux/include/sqlite3_vec/sqlite3_vec_plugin.h b/packages/sqlite3_vec/linux/include/sqlite3_vec/sqlite3_vec_plugin.h
new file mode 100644
index 00000000..89a85777
--- /dev/null
+++ b/packages/sqlite3_vec/linux/include/sqlite3_vec/sqlite3_vec_plugin.h
@@ -0,0 +1,26 @@
+#ifndef FLUTTER_PLUGIN_SQLITE3_VEC_PLUGIN_H_
+#define FLUTTER_PLUGIN_SQLITE3_VEC_PLUGIN_H_
+
+#include
+
+G_BEGIN_DECLS
+
+#ifdef FLUTTER_PLUGIN_IMPL
+#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
+#else
+#define FLUTTER_PLUGIN_EXPORT
+#endif
+
+typedef struct _Sqlite3VecPlugin Sqlite3VecPlugin;
+typedef struct {
+ GObjectClass parent_class;
+} Sqlite3VecPluginClass;
+
+FLUTTER_PLUGIN_EXPORT GType sqlite3_vec_plugin_get_type();
+
+FLUTTER_PLUGIN_EXPORT void sqlite3_vec_plugin_register_with_registrar(
+ FlPluginRegistrar* registrar);
+
+G_END_DECLS
+
+#endif // FLUTTER_PLUGIN_SQLITE3_VEC_PLUGIN_H_
diff --git a/packages/sqlite3_vec/linux/sqlite3_vec_plugin.cc b/packages/sqlite3_vec/linux/sqlite3_vec_plugin.cc
new file mode 100644
index 00000000..bea47954
--- /dev/null
+++ b/packages/sqlite3_vec/linux/sqlite3_vec_plugin.cc
@@ -0,0 +1,76 @@
+#include "include/sqlite3_vec/sqlite3_vec_plugin.h"
+
+#include
+#include
+#include
+
+#include
+
+#include "sqlite3_vec_plugin_private.h"
+
+#define SQLITE3_VEC_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), sqlite3_vec_plugin_get_type(), \
+ Sqlite3VecPlugin))
+
+struct _Sqlite3VecPlugin {
+ GObject parent_instance;
+};
+
+G_DEFINE_TYPE(Sqlite3VecPlugin, sqlite3_vec_plugin, g_object_get_type())
+
+// Called when a method call is received from Flutter.
+static void sqlite3_vec_plugin_handle_method_call(
+ Sqlite3VecPlugin* self,
+ FlMethodCall* method_call) {
+ g_autoptr(FlMethodResponse) response = nullptr;
+
+ const gchar* method = fl_method_call_get_name(method_call);
+
+ if (strcmp(method, "getPlatformVersion") == 0) {
+ response = get_platform_version();
+ } else {
+ response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
+ }
+
+ fl_method_call_respond(method_call, response, nullptr);
+}
+
+FlMethodResponse* get_platform_version() {
+ struct utsname uname_data = {};
+ uname(&uname_data);
+ g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version);
+ g_autoptr(FlValue) result = fl_value_new_string(version);
+ return FL_METHOD_RESPONSE(fl_method_success_response_new(result));
+}
+
+static void sqlite3_vec_plugin_dispose(GObject* object) {
+ G_OBJECT_CLASS(sqlite3_vec_plugin_parent_class)->dispose(object);
+}
+
+static void sqlite3_vec_plugin_class_init(Sqlite3VecPluginClass* klass) {
+ G_OBJECT_CLASS(klass)->dispose = sqlite3_vec_plugin_dispose;
+}
+
+static void sqlite3_vec_plugin_init(Sqlite3VecPlugin* self) {}
+
+static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call,
+ gpointer user_data) {
+ Sqlite3VecPlugin* plugin = SQLITE3_VEC_PLUGIN(user_data);
+ sqlite3_vec_plugin_handle_method_call(plugin, method_call);
+}
+
+void sqlite3_vec_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
+ Sqlite3VecPlugin* plugin = SQLITE3_VEC_PLUGIN(
+ g_object_new(sqlite3_vec_plugin_get_type(), nullptr));
+
+ g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
+ g_autoptr(FlMethodChannel) channel =
+ fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
+ "sqlite3_vec",
+ FL_METHOD_CODEC(codec));
+ fl_method_channel_set_method_call_handler(channel, method_call_cb,
+ g_object_ref(plugin),
+ g_object_unref);
+
+ g_object_unref(plugin);
+}
diff --git a/packages/sqlite3_vec/linux/sqlite3_vec_plugin_private.h b/packages/sqlite3_vec/linux/sqlite3_vec_plugin_private.h
new file mode 100644
index 00000000..23b3b496
--- /dev/null
+++ b/packages/sqlite3_vec/linux/sqlite3_vec_plugin_private.h
@@ -0,0 +1,10 @@
+#include
+
+#include "include/sqlite3_vec/sqlite3_vec_plugin.h"
+
+// This file exposes some plugin internals for unit testing. See
+// https://github.com/flutter/flutter/issues/88724 for current limitations
+// in the unit-testable API.
+
+// Handles the getPlatformVersion method call.
+FlMethodResponse *get_platform_version();
diff --git a/packages/sqlite3_vec/linux/test/sqlite3_vec_plugin_test.cc b/packages/sqlite3_vec/linux/test/sqlite3_vec_plugin_test.cc
new file mode 100644
index 00000000..1d7c3c47
--- /dev/null
+++ b/packages/sqlite3_vec/linux/test/sqlite3_vec_plugin_test.cc
@@ -0,0 +1,31 @@
+#include
+#include
+#include
+
+#include "include/sqlite3_vec/sqlite3_vec_plugin.h"
+#include "sqlite3_vec_plugin_private.h"
+
+// This demonstrates a simple unit test of the C portion of this plugin's
+// implementation.
+//
+// Once you have built the plugin's example app, you can run these tests
+// from the command line. For instance, for a plugin called my_plugin
+// built for x64 debug, run:
+// $ build/linux/x64/debug/plugins/my_plugin/my_plugin_test
+
+namespace sqlite3_vec {
+namespace test {
+
+TEST(Sqlite3VecPlugin, GetPlatformVersion) {
+ g_autoptr(FlMethodResponse) response = get_platform_version();
+ ASSERT_NE(response, nullptr);
+ ASSERT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
+ FlValue* result = fl_method_success_response_get_result(
+ FL_METHOD_SUCCESS_RESPONSE(response));
+ ASSERT_EQ(fl_value_get_type(result), FL_VALUE_TYPE_STRING);
+ // The full string varies, so just validate that it has the right format.
+ EXPECT_THAT(fl_value_get_string(result), testing::StartsWith("Linux "));
+}
+
+} // namespace test
+} // namespace sqlite3_vec
diff --git a/packages/sqlite3_vec/pubspec.yaml b/packages/sqlite3_vec/pubspec.yaml
new file mode 100644
index 00000000..4ce9b7b5
--- /dev/null
+++ b/packages/sqlite3_vec/pubspec.yaml
@@ -0,0 +1,72 @@
+name: sqlite3_vec
+description: "A new Flutter plugin project."
+version: 0.0.1
+homepage:
+
+environment:
+ sdk: ^3.6.0
+ flutter: '>=3.3.0'
+
+dependencies:
+ flutter:
+ sdk: flutter
+ sqlite3: ^2.6.0
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
+ lint: ^2.3.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter packages.
+flutter:
+ # This section identifies this Flutter project as a plugin project.
+ # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
+ # which should be registered in the plugin registry. This is required for
+ # using method channels.
+ # The Android 'package' specifies package in which the registered class is.
+ # This is required for using method channels on Android.
+ # The 'ffiPlugin' specifies that native code should be built and bundled.
+ # This is required for using `dart:ffi`.
+ # All these are used by the tooling to maintain consistency when
+ # adding or updating assets for this project.
+ plugin:
+ platforms:
+ android:
+ package: me.movenext.sqlite3_vec
+ pluginClass: Sqlite3VecPlugin
+ linux:
+ pluginClass: Sqlite3VecPlugin
+
+ # To add assets to your plugin package, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+ #
+ # For details regarding assets in packages, see
+ # https://flutter.dev/to/asset-from-package
+ #
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.dev/to/resolution-aware-images
+
+ # To add custom fonts to your plugin package, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts in packages, see
+ # https://flutter.dev/to/font-from-package