From 94c4c1a8e0e5acb7af5756e684820aa0423c7936 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Tue, 25 Jul 2023 23:24:08 +0200 Subject: [PATCH] Document #2537 better --- docs/pages/docs/Getting started/index.md | 30 +------------- .../docs/Getting started/starting_with_sql.md | 29 +------------- docs/templates/partials/changed_to_ffi.html | 15 ------- docs/templates/partials/dependencies.html | 39 +++++++++++++++++++ drift_dev/build.yaml | 8 ++-- 5 files changed, 46 insertions(+), 75 deletions(-) delete mode 100644 docs/templates/partials/changed_to_ffi.html create mode 100644 docs/templates/partials/dependencies.html diff --git a/docs/pages/docs/Getting started/index.md b/docs/pages/docs/Getting started/index.md index 2c6bea96..fd4d4554 100644 --- a/docs/pages/docs/Getting started/index.md +++ b/docs/pages/docs/Getting started/index.md @@ -15,37 +15,11 @@ how to get started. You can watch it [here](https://youtu.be/zpWsedYMczM). A complete cross-platform Flutter app using drift is also available [here](https://github.com/simolus3/drift/tree/develop/examples/app). ## Adding the dependency -First, lets add drift to your project's `pubspec.yaml`. -At the moment, the current version of `drift` is [![Drift version](https://img.shields.io/pub/v/drift.svg)](https://pub.dev/packages/drift) -and the latest version of `drift_dev` is [![Generator version](https://img.shields.io/pub/v/drift_dev.svg)](https://pub.dev/packages/drift_dev). -{% assign versions = 'package:drift_docs/versions.json' | readString | json_decode %} +{% include "partials/dependencies" %} + {% assign snippets = 'package:drift_docs/snippets/tables/filename.dart.excerpt.json' | readString | json_decode %} -```yaml -dependencies: - drift: ^{{ versions.drift }} - sqlite3_flutter_libs: ^0.5.0 - path_provider: ^2.0.0 - path: ^{{ versions.path }} - -dev_dependencies: - drift_dev: ^{{ versions.drift_dev }} - build_runner: ^{{ versions.build_runner }} -``` - -If you're wondering why so many packages are necessary, here's a quick overview over what each package does: - -- `drift`: This is the core package defining most apis -- `sqlite3_flutter_libs`: Ships the latest `sqlite3` version with your Android or iOS app. This is not required when you're _not_ using Flutter, - but then you need to take care of including `sqlite3` yourself. - For an overview on other platforms, see [platforms]({{ '../platforms.md' | pageUrl }}). -- `path_provider` and `path`: Used to find a suitable location to store the database. Maintained by the Flutter and Dart team -- `drift_dev`: This development-only dependency generates query code based on your tables. It will not be included in your final app. -- `build_runner`: Common tool for code-generation, maintained by the Dart team - -{% include "partials/changed_to_ffi" %} - ### Declaring tables Using drift, you can model the structure of your tables with simple dart code. diff --git a/docs/pages/docs/Getting started/starting_with_sql.md b/docs/pages/docs/Getting started/starting_with_sql.md index 70cc3315..933ed494 100644 --- a/docs/pages/docs/Getting started/starting_with_sql.md +++ b/docs/pages/docs/Getting started/starting_with_sql.md @@ -12,35 +12,8 @@ declaring both tables and queries in Dart. This version will focus on how to use A complete cross-platform Flutter app using drift is also available [here](https://github.com/simolus3/drift/tree/develop/examples/app). ## Adding the dependency -First, lets add drift to your project's `pubspec.yaml`. -At the moment, the current version of `drift` is [![Drift version](https://img.shields.io/pub/v/drift.svg)](https://pub.dev/packages/drift) -and the latest version of `drift_dev` is [![Generator version](https://img.shields.io/pub/v/drift_dev.svg)](https://pub.dev/packages/drift_dev). -{% assign versions = 'package:drift_docs/versions.json' | readString | json_decode %} - -```yaml -dependencies: - drift: ^{{ versions.drift }} - sqlite3_flutter_libs: ^0.5.0 - path_provider: ^2.0.0 - path: ^{{ versions.path }} - -dev_dependencies: - drift_dev: ^{{ versions.drift_dev }} - build_runner: ^{{ versions.build_runner }} -``` - -If you're wondering why so many packages are necessary, here's a quick overview over what each package does: - -- `drift`: This is the core package defining most apis -- `sqlite3_flutter_libs`: Ships the latest `sqlite3` version with your Android or iOS app. This is not required when you're _not_ using Flutter, - but then you need to take care of including `sqlite3` yourself. - For an overview on other platforms, see [platforms]({{ '../platforms.md' | pageUrl }}). -- `path_provider` and `path`: Used to find a suitable location to store the database. Maintained by the Flutter and Dart team -- `drift_dev`: This development-only dependency generates query code based on your tables. It will not be included in your final app. -- `build_runner`: Common tool for code-generation, maintained by the Dart team - -{% include "partials/changed_to_ffi" %} +{% include "partials/dependencies" %} ## Declaring tables and queries diff --git a/docs/templates/partials/changed_to_ffi.html b/docs/templates/partials/changed_to_ffi.html deleted file mode 100644 index 9129ae86..00000000 --- a/docs/templates/partials/changed_to_ffi.html +++ /dev/null @@ -1,15 +0,0 @@ - - -Some versions of the Flutter tool create a broken `settings.gradle` on Android, which can cause problems with `drift/native.dart`. -If you get a "Failed to load dynamic library" exception, see [this comment](https://github.com/flutter/flutter/issues/55827#issuecomment-623779910). \ No newline at end of file diff --git a/docs/templates/partials/dependencies.html b/docs/templates/partials/dependencies.html new file mode 100644 index 00000000..534f8bd0 --- /dev/null +++ b/docs/templates/partials/dependencies.html @@ -0,0 +1,39 @@ +{% block "blocks/markdown" %} + +First, lets add drift to your project's `pubspec.yaml`. +At the moment, the current version of `drift` is [![Drift version](https://img.shields.io/pub/v/drift.svg)](https://pub.dev/packages/drift) +and the latest version of `drift_dev` is [![Generator version](https://img.shields.io/pub/v/drift_dev.svg)](https://pub.dev/packages/drift_dev). + +{% assign versions = 'package:drift_docs/versions.json' | readString | json_decode %} + +```yaml +dependencies: + drift: ^{{ versions.drift }} + sqlite3_flutter_libs: ^0.5.0 + path_provider: ^2.0.0 + path: ^{{ versions.path }} + +dev_dependencies: + drift_dev: ^{{ versions.drift_dev }} + build_runner: ^{{ versions.build_runner }} +``` + +If you're wondering why so many packages are necessary, here's a quick overview over what each package does: + +- `drift`: This is the core package defining the APIs you use to access drift databases. +- `sqlite3_flutter_libs`: Ships the latest `sqlite3` version with your Android or iOS app. This is not required when you're _not_ using Flutter, + but then you need to take care of including `sqlite3` yourself. + For an overview on other platforms, see [platforms]({{ '../platforms.md' | pageUrl }}). + Note that the `sqlite3_flutter_libs` package will include the native sqlite3 library for the following + architectures: `armv8`, `armv7`, `x86` and `x86_64`. + Most Flutter apps don't run on 32-bit x86 devices without further setup, so you should + [add a snippet](https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3_flutter_libs#included-platforms) + to your `build.gradle` if you don't need `x86` builds. + Otherwise, the Play Store might allow users on `x86` devices to install your app even though it is not + supported. + In Flutter's current native build system, drift unfortunately can't do that for you. +- `path_provider` and `path`: Used to find a suitable location to store the database. Maintained by the Flutter and Dart team. +- `drift_dev`: This development-only dependency generates query code based on your tables. It will not be included in your final app. +- `build_runner`: Common tool for code-generation, maintained by the Dart team. + +{% endblock %} \ No newline at end of file diff --git a/drift_dev/build.yaml b/drift_dev/build.yaml index 5faeee00..3b806dbb 100644 --- a/drift_dev/build.yaml +++ b/drift_dev/build.yaml @@ -1,14 +1,14 @@ # Short description for each builder -# - preparing_builder: Infers the type of inline Dart expressions in moor files. +# - preparing_builder: Infers the type of inline Dart expressions in drift files. # We create a `input.temp.dart` file containing the expressions so that they # can be resolved. -# - moor_generator: The regular SharedPartBuilder for @UseMoor and @UseDao +# - drift_dev: The regular SharedPartBuilder for @DriftDatabase and @DriftAccessor # annotations -# - moor_generator_not_shared: Like moor_generator, but as a PartBuilder instead of +# - not_shared: Like drift_dev, but as a PartBuilder instead of # a SharedPartBuilder. This builder is disabled by default, but users may choose # to use it so that generated classes can be used by other builders. -# - moor_cleanup: Deletes the `.temp.dart` files generated by the `preparing_builder`. +# - cleanup: Deletes the `.temp.dart` files generated by the `preparing_builder`. builders: preparing_builder: