Skip to content

Commit

Permalink
Expand readme
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Oct 13, 2024
1 parent 3dc5835 commit 3395710
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion sqlite3/example/custom_extension/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# uuid.c example

Custom SQLite extension (uuid.c) loaded in sqlite3.
This example shows how to load SQLite extensions into Flutter apps using `sqlite3_flutter_libs`.
As an example, it uses the [uuid.c](https://github.com/sqlite/sqlite/blob/master/ext/misc/uuid.c)
extension, but other extensions can be adapted similarly.

To build the extension:

1. A `CMakeLists.txt` (in `src/`) is written for Android, Linux and Windows.
2. On Android, the NDK is set up to point at the CMake builds in `android/build.gradle`.
3. For macOS and iOS (which don't use CMake as a build tool), the `uuid.c` file is added
to `macos|ios/Classes` instead.
4. Note that this example does not currently support WebAssembly. Loadable extensions don't
work on the web, but you can compile a custom `sqlite3.wasm` bundle with the desired extensions
included. The `../custom_wasm_build` example has an example for that setup.

This build setup includes a shared library with the extension in your app. To use it, load the
`DynamicLibrary` and then load it into sqlite3 like this:

```dart
sqlite3.ensureExtensionLoaded(
SqliteExtension.inLibrary(uuid.lib, 'sqlite3_uuid_init'),
);
```
2 changes: 1 addition & 1 deletion sqlite3/example/custom_extension/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:

uuid:
path: ../

cupertino_icons: ^1.0.6
sqlite3: ^2.4.6
sqlite3_flutter_libs: ^0.5.24
Expand Down

0 comments on commit 3395710

Please sign in to comment.