Redeem Now
Read More
Read now

Flutter sqflite database


Flutter sqflite database

In this blog, we are going to learn about Flutter sqflite database integration. the SQLite plugin for the flutter application. We create a demo app in which we have an edit text for the values, a button at this button tap we add the values to the database and also we use a list view to show all the values from the database. We also add a delete button in the listview item view on the press of this delete button that item value will be deleted from the database.

I hope by this example you will know about creating the database, insert query, delete query, getting all the values from the database.

Sqflite is a plugin for flutter to integrate the SQLite database in flutter projects.

Getting Started :

First of all, you have to install the dependency in your pubspec.yaml l file in your flutter project.

There are some more useful dependencies to integrate the sqflite database.

We have added path_provider dependency which is used for finding commonly used locations on the filesystem. Supports iOS, Android, Linux, and macOS. Not all methods are supported on all platforms.

We also use the path plugin which is used for manipulating paths: joining, splitting, normalizing, etc.

After that, we are going to create a helper class (DBHelper.dart) in this we are creating the database in this class we have some methods to perform queries on the database.

getTextList() => To get all the values that is inserted in database it will return Future<List<Map>>

addText()=> addText method to insert the values in the database it will return Future<String>.

deleteText()=> deleteText to perform delete query.

DBHelper.dart :

After this DBHelper class, we just have to make the view. In this view, we have an edit text that is for values that we want to add to the database. Below of the edit text we have and the list view that will iterate the values that is stored in the database. Last thing we have a floating action button on this button tap we will insert the value in the database.

main.dart :

In conclusion, We have completed Flutter sqflite database integration blog.

Hope this blog will help you to integrate sqflite database.

SQFlte –>

Path Provider–>


. . .


Add Your Comment

Be the first to comment.