Moor is a powerful library for using an SQLite database from your Flutter apps by writing pure Dart code. In the first part of this series, we’ve only touched the basics of this package. Let’s now take a look at some of the more advanced queries and also how to keep your code clean by separating it into Data Access Objects.

All of the code for queries currently lives inside the AppDatabase class itself. At the moment, that’s perfectly fine - we are only dealing with Tasks. We have to think into the future though. Once we would start adding comments, habits and who knows what else into the app, placing all of the queries together would create a mess.

To separate the queries dealing with tasks (and in the future, with comments and habits), we can use data access objects (DAOs). The functionality of the queries will remain unchanged, they will only be moved to a new and cleaner place.

#flutter #dart #database #developer

Moor (Room for Flutter) – Advanced Queries & DAOs – Fluent SQLite Database
24.40 GEEK