In this flutter tutorial I will explain how to use SQLite in your Flutter projects. You will learn how to :
- Use SQLite in your Flutter application
- Manage your SQLite database and tables
- Create Read Update and delete records
Versions
First take a look at the software version I used in this tutorial :
- Flutter 2.0.6
- Android Studio 4.2
You can also take a look to the Github repository of this tutorial here.
1. Install dependencies to use SQLite in your project
First you need to install two dependencies in your project.
- sqflite to manage SQLite database.
- path_provider to manage file path on device andhelp to retrieve the SQLite database file you will create soon.
To do that make this changes in the dependencies section in pubspec.yaml
//...
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2 ## Add the 2 lines below
sqflite: ^2.0.0+3 # Needed for SQLite use
path_provider: ^2.0.1 # Needed to retrieve database file on device
dev_dependencies:
//...