2. Create a DB Client

Now in your project create a new file Database.dart . In the newly created file, we need to create a singleton.

Why we need singleton: We use the singleton pattern to ensure that we have only one class instance and provide a global point access to it

1.Create a private constructor that can be used only inside the class :

2.Setup the database

Next we will create the database object and provide it with a getter where we will instantiate the database if it’s not (lazy initialization).

If there is no object assigned to the database, we use the initDB function to create the database. In this function, we will get the path for storing the database and create the desired tables: