From 226aead4c0909f5f9dc0ab14afd2a00cc9ee9d0b Mon Sep 17 00:00:00 2001 From: Elmarakbeno <43115402+abdelrahmanelmarakby@users.noreply.github.com> Date: Sat, 24 Sep 2022 08:06:49 +0200 Subject: [PATCH] Add getx example to FAQ (#2077) --- docs/pages/docs/faq.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/pages/docs/faq.md b/docs/pages/docs/faq.md index e391a2c6..23bf356e 100644 --- a/docs/pages/docs/faq.md +++ b/docs/pages/docs/faq.md @@ -37,6 +37,16 @@ void main() { } ``` Your widgets would then have access to the database using `Provider.of(context)`. +### GetX +If you're using the [GetX](https://pub.dev/packages/get) package, you can add it as a service that manages the database instance:. + +```dart +void main() { + Get.put(MyDatabase()); + runApp(MyFlutterApp()); +} +``` +Your widgets would then have access to the database using `Get.find().your_method`. ### A more complex architecture If you're strict on keeping your business logic out of the widget layer, you probably use some dependency injection