This content originally appeared on Level Up Coding - Medium and was authored by Nabin Dhakal
If you are seeking a way to use the mobile device storage as a database in your Flutter application, then you can obtain it by just integrating the sqflite package.
In this article, we are going to learn about CRUD operations with SQLite and Flutter. Our final application works as follows:
In this project, we are going to save the title and description in our database.
Step 1. Add the dependencies
You need to add the sqflite package in the pubsec.yaml file of your project.
- sqflite: The SQLite package to integrate SQLite database functions.
dependencies:
...
sqflite: ^2.0.2+1
Step 2. Create a database
Create a file named database_helper. Inside were, we then create the database and tables.
Step 3. Open the database
Step 4. Perform the CRUD operations
- Adding/Create Item
Next, we write the method to insert our items into the database. This method takes two parameters one is the title and the other is the description.
2. Read Item
3. Edit/Update Item
4. Delete item
The database_helper.dart file looks as follows:
Step 5. Creating the form and displaying
Create a file named homepage.dart where we create the form and display our data in lists.
Let’s get connected
We can be friends. Find on Facebook, Linkedin, Github, and Instagram.
Conclusion
I hope this article is helpful to you and you learned new things. I have used various things in this article that might be new for some of you.
If you learned something new or want to suggest something then please let me know in the comment.
If you loved the article click on 👏 icon which provides motivation on delivering you all the new things.
Also, follow to get updated on exciting articles and projects.
Learning by sharing gives a great impact on the learning process and makes the community bigger and bigger.
Sharing is a magnet that attracts other enthusiasts toward you.
Hence, let’s take a small step toward making our learning community bigger.
Share this article with your friends or tweet about the article if you loved it.
Get full at:
GitHub - nbnD/sqlite_crud: CRUD with SQLite in flutter
CRUD with SQLite was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Nabin Dhakal
Nabin Dhakal | Sciencx (2022-07-01T18:09:01+00:00) CRUD with SQLite. Retrieved from https://www.scien.cx/2022/07/01/crud-with-sqlite/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.