Flutter SQLite example – CRUD operations with sqflite plugin

In this tutorial, we’re gonna look at how to make SQLite CRUD Operations in a Flutter App using sqflite plugin.

More Practice: Flutter SQLite example – CRUD Operations with ListView & sqflite plugin

Flutter SQLite CRUD with sqflite

Import sqflite

Add sqflite plugin to the dependencies section of our pubspec.yaml:

Open a Database

First, we find a location path for the database using getDatabasesPath() function. Then we call openDatabase() with onCreate() callback method where we populate data.

CRUD Operations
Create an Item

Or use raw Query:

Read All Items

Or use raw Query:

Read an Item

Or use raw Query:

Update an Item

Or use raw Query:

Delete an Item

Or use raw Query:

Close the Database

Practice

Import sqflite

Add sqflite plugin to the dependencies section of our pubspec.yaml:

Create Data Model

lib/model/note.dart

Create Database Helper Class

lib/util/database_helper.dart

Main for testing

lib/main.dart

Run & Check Results

In Console:

Source Code

sqlite_example

By grokonez | July 16, 2018.



Related Posts


2 thoughts on “Flutter SQLite example – CRUD operations with sqflite plugin”

  1. Why we use these codes :

Got Something To Say:

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

*