DEV Community

loizenai
loizenai

Posted on

Flutter SQLite example - CRUD Operations with ListView & sqflite plugin

https://grokonez.com/flutter/flutter-sqlite-example-listview-crud-operations-sqflite-plugin

Flutter SQLite example - CRUD Operations with ListView & sqflite plugin

In previous post, we knew how to make SQLite CRUD Operations using sqflite plugin. In this tutorial, we're gonna build a Flutter App that allows us to make CRUD interactions with SQLite in a ListView.

Related Post:

Firebase:

Example Overview

Goal

Our Flutter App will retrieve list of Notes from SQLite Database and show it in ListView widget. Then we can click on Add button to create new Note, click on a Note item to update that Note, or delete a Note with remove Button.

flutter-sqlite-example-listview-sqflite-overview

Project Structure

flutter-sqlite-example-listview-sqflite-structure

  • Note class (note.dart) is a Data Model.
  • DatabaseHelper class (database_helper.dart) handles CRUD Operations with SQLite using sqflite plugin.
  • ListViewNote (listview_note.dart) is a StatefulWidget with List<Note> is state variable. It shows the list using ListView.builder, sends/gets data to/from NoteScreen using Navigator.
  • NoteScreen (note_screen.dart) is the user interface for adding/updating Note.
  • We add sqflite dependency in pubspec.yaml.

For more detailsa about ListView and Navigator, please visit:

More: https://grokonez.com/flutter/flutter-sqlite-example-listview-crud-operations-sqflite-plugin

Top comments (0)