Skip to content
Back

[Solved] Design patterns with Appwrite Flutter

  • 0
  • General
  • Flutter
  • Databases
nebukadnezar
24 Oct, 2023, 10:31

I'm having trouble using Appwrite. More in a sense of how do I organise my code. This is because I'm learning coding/Flutter and started using Appwrite as my backend.

I've been using the Flutter provider package and I've been wondering, are fellow Flutter devs also making an Appwrite provider in which you can call the various functions? I would love to hear your stories and I hope to get some insight and eventually a direction(s?) in which I can go at it.

Just to give some context, I have an app in which I want to create notes after my workout. I've designed the screens and models. Now got stuck on something simple. Importing Appwrite in every page is not really maintainable; So what are my options?

I've added some screenshots for context. Thank you in advance fam! ❤️

TL;DR
The user is seeking advice on organizing their code while using Appwrite with Flutter. They have been using the Flutter provider package and are wondering if other Flutter developers are creating an Appwrite provider for calling various functions. The user is specifically trying to create notes in their app after a workout. They are looking for suggestions on how to avoid importing Appwrite in every page and make their code more maintainable. No solution is provided in the thread.
dammy
24 Oct, 2023, 12:05

there is an existing AppWrite flutter package @nebukadnezar

dammy
24 Oct, 2023, 12:06
nebukadnezar
24 Oct, 2023, 17:01

Thank you for replying. I meant as in how to architect a Flutter app with Appwrite? I'm reading about repository pattern for example

Drake
24 Oct, 2023, 17:23

when reading about stuff online, i would read for general architecture/organization and then apply those using Appwrite.

For example, a common approach is to create repositories or services for your business logic or resources so the appwrite SDK would be used in one of those classes

alterhuman
25 Oct, 2023, 06:08

Create service classes that create different methods like createNewNote, deleteNote etc. and then create providers that call those service methods. And use the providers everywhere in your app.

nebukadnezar
25 Oct, 2023, 16:19

thank you; this is insightful feedback. Do you use interfaces to make it more modular?

alterhuman
26 Oct, 2023, 05:44

What do you mean by interfaces in dart?

nebukadnezar
26 Oct, 2023, 11:54

I mean to have to a service class with the different methods just as you said. Also creating an interface that the service uses if I ever want to change my service in the future. Would that be a good idea?

alterhuman
27 Oct, 2023, 03:19

I directly define the methods & change the logic in the service class. You can also use an interface (abstract class) for easier mock testing but I don't do it.

In both ways the main benefit is you don't have to change the provider and any of its use in the app even if you decide to change a service.

nebukadnezar
27 Oct, 2023, 11:04

Thanks man, I'll give it a go

Drake
8 Nov, 2023, 01:03

Need anything else or can this be marked as solved?

nebukadnezar
8 Nov, 2023, 08:53

Thanks Steve, you can mark this as solved. I don’t know how to do that 🫣

nebukadnezar
8 Nov, 2023, 10:06

[Solved] Design patterns with Appwrite Flutter

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more