From 594b5f43c54cf03218099c895f2ada5ff12d0b09 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Sat, 30 Oct 2021 17:04:24 +0200 Subject: [PATCH] Explain that channels need to be initialized --- docs/pages/docs/Getting started/index.md | 13 +++++++++++++ .../docs/Getting started/starting_with_sql.md | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/pages/docs/Getting started/index.md b/docs/pages/docs/Getting started/index.md index 49243fbe..3c207672 100644 --- a/docs/pages/docs/Getting started/index.md +++ b/docs/pages/docs/Getting started/index.md @@ -123,3 +123,16 @@ class MyDatabase extends _$MyDatabase { Congratulations! You're now ready to use all of drift. See the articles below for further reading. The ["Writing queries"]({{ "writing_queries.md" | pageUrl }}) article contains everything you need to know to write selects, updates and inserts in drift! + +{% block "blocks/alert" title="Using the database" %} +> The database class from this guide is ready to be used with your app. + For Flutter apps, a Drift database class is typically instantiated at the top of your widget tree + and then passed down with `provider` or `riverpod`. + See [using the database]({{ '../faq.md#using-the-database' | pageUrl }}) for ideas on how to integrate + Drift into your app's state management. + + The setup in this guide uses [platform channels](https://flutter.dev/docs/development/platform-integration/platform-channels), + which are only available after running `runApp` by default. + When using drift before your app is initialized, please call `WidgetsFlutterBinding.ensureInitialized()` before using + the database to ensure that platform channels are ready. +{% endblock %} diff --git a/docs/pages/docs/Getting started/starting_with_sql.md b/docs/pages/docs/Getting started/starting_with_sql.md index b8b77bcf..6a7a6302 100644 --- a/docs/pages/docs/Getting started/starting_with_sql.md +++ b/docs/pages/docs/Getting started/starting_with_sql.md @@ -170,4 +170,17 @@ further guides to help you learn more: - Writing [queries]({{ "writing_queries.md" | pageUrl }}) and [expressions]({{ "../Advanced Features/expressions.md" | pageUrl }}) in Dart - A more [in-depth guide]({{ "../Using SQL/moor_files.md" | pageUrl }}) - on `drift` files, which explains `import` statements and the Dart-SQL interop. \ No newline at end of file + on `drift` files, which explains `import` statements and the Dart-SQL interop. + +{% block "blocks/alert" title="Using the database" %} +> The database class from this guide is ready to be used with your app. + For Flutter apps, a Drift database class is typically instantiated at the top of your widget tree + and then passed down with `provider` or `riverpod`. + See [using the database]({{ '../faq.md#using-the-database' | pageUrl }}) for ideas on how to integrate + Drift into your app's state management. + + The setup in this guide uses [platform channels](https://flutter.dev/docs/development/platform-integration/platform-channels), + which are only available after running `runApp` by default. + When using drift before your app is initialized, please call `WidgetsFlutterBinding.ensureInitialized()` before using + the database to ensure that platform channels are ready. +{% endblock %}