Simple SQFlite database example in Flutter

2 min readJan 8, 2019

Code updated on December 15, 2022

There are a number of tutorials out there about how to setup a SQLite database in Flutter using the SQFlite plugin. They were helpful but I found myself getting lost in the details. My purpose in this post is to give you a minimal example that you can get through in 10 minutes. Once you have it working, you can go on to some of the more advanced topics in other tutorials.

Here is the minimal app that you will be making:

Pressing each button will perform the related operation on the database using SQFlite.

For this minimal example, you will do the following steps:

  1. Add the dependencies
  2. Make a database helper class
  3. Make your app layout with the button logic

Start by creating a new Flutter project called flutter_database.


Open the pubspec.yaml file and add the following lines to the dependencies section:

sqflite: ^2.2.2
path_provider: ^2.0.11
path: ^1.8.2

You can find the current versions for these packages here:

Database helper

Create a new file in the lib folder and call it database_helper.dart.

Copy in the following code:

App code

Open your main.dart file and replace it with the following code:


Flutter and Dart developer. Twitter: @suragch1