dart-sdk/samples/ffi/sqlite
Oleh Prypin 732d1cc0a4 Revert "Add more interface and final modifiers to dart:core."
This reverts commit 4f8333e80e.

Reason for revert: causes breakages in google3

Original change's description:
> Add more `interface` and `final` modifiers to `dart:core`.
>
> Make intent explicit for classes which are intended as interfaces,
> or which are not intended to be subclassed.
>
> Mainly classes which are pure interfaces are marked as such,
> and platform-specific classes not intended for subclassing
> are made `final`.
>
> The `final` classes includes `BigInt`, which is written to assume
> that arguments inherit its private members
> (it runs `_ensureSystemBigInt` on arguments).
>
> It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
> which are just intended as stand-alone implementation classes for accessing
> platform-specific functionality.
>
> Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I94ff95f72410a4e1ae80744971c4c920fecc1493
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287760
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-03-09 13:09:57 +00:00
..
docs [samples/ffi] Update sqlite-tutorial 2023-02-21 21:23:43 +00:00
example
lib Revert "Add more interface and final modifiers to dart:core." 2023-03-09 13:09:57 +00:00
test [tests] Avoid small --optimization-counter-threshold in tests 2022-10-10 21:04:18 +00:00
.gitignore
pubspec.yaml [samples/ffi] Update sqlite sample 2022-06-07 12:11:39 +00:00
README.md [samples/ffi] Update sqlite sample 2022-06-07 12:11:39 +00:00

Sample code dart:ffi

This is an illustrative sample for how to use dart:ffi.

Prerequirement

For Windows, Linux, and MacOS, you should make sure, sqlite dev lib installed on your system.

Windows user can download dll from https://www.sqlite.org/download.html

If you do not have any sqlite3.dll or so file, you may found error message:

Unhandled exception:
Invalid argument(s): Failed to load dynamic library (126)
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:13:55)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)

Building and Running this Sample

Building and running this sample is done through pub. Running dart run example/main should produce the following output.

$ dart run example/main
1 Chocolade chip cookie Chocolade cookie foo
2 Ginger cookie null 42
3 Cinnamon roll null null
1 Chocolade chip cookie Chocolade cookie foo
2 Ginger cookie null 42
expected exception on accessing result data after close: The result has already been closed.
expected this query to fail: no such column: non_existing_column (Code 1: SQL logic error)

Tutorial

A tutorial walking through the code is available in docs/sqlite-tutorial.md. For information on how to use this package within a Flutter app, see docs/android.md. (Note: iOS is not yet supported).