Moor Database

Updated 29 April 2023


What is the need for Moor Database?

When we begin to develop the applications, there comes a time when we find ourselves with the need to save the data within the application itself for offline support or for user-generated data.

At that point, what we do is introduce a database in the development of the application.
Moor is one of the options available for flutter.


This is a reactive persistence library for Flutter and Dart, built on top of SQLite.

It is a layer that sits on top of an SQLite database and makes it easier to use.

Looking out for someĀ Flutter app development services

Let’s start the implementation

Add packages in your pubspec.yaml file.


Create a table according to your needs.

Database Class

In this class, you have to register all your data tables and write the methods for your database.

After that, run command – flutter pub run build_runner build as a result, this command will create the code for moor database.

Query Executor

A query executor is responsible for executing statements on a database and return their results in a raw form.

Now, all things are set up and we can move forward to the main view.

Step 1: Create a singleton object of your database class.

Step 2: Let’s Create the functions for our database.

I have used static data for demonstration you can change it according to you

Step 3: Let’s show the data on UI with the stream builder

For more details, pleaae check Moor Database

Hopefully, this blog will be helpful to you. If you have any query, please write it in comment section.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home