Introduction
In this article, we will understand the Firestore setup in Firebase and integrate Firestore database in Flutter. We will perform CRUD operations using Flutter in Firestore.
Firebase is a Google Cloud Platform which provides cloud services like authentication, real-time database (NoSQL database), storage (Image, audio, video, etc.), Hosting, Cloud Functions, Analytics, etc. We have already discussed authentication in my other articles. If you haven’t read it yet, you can check it here.
Now, we will understand the Firestore implementation in Flutter.
Prerequisites (Firebase Project Setup)
-
To set up a Firebase project, please check my other article and follow the first 2 steps. Please note that you need to follow only the first 2 steps.
-
Now, in a Firebase project, go to the database tab and add a new Firestore database and select region to create it.
-
You need to add a root collection. By clicking “Start Collection”, you can add it. Click on "Start Collection" and give the Collection Id as students.
You are all done with setting the Firebase project.
CRUD Operation in Flutter
Open the pubspec.yaml file in your project and add the following dependencies into it.
- dependencies:
- flutter:
- sdk: flutter
- cupertino_icons: ^0.1.2
- cloud_firestore: ^0.12.7
Save the file and run the flutter pub get command on terminal.
We will take some important topics that we need to understand. Download the full source code attached with this article. Following are those topics -
Go to main.dart and import,
- import 'package:cloud_firestore/cloud_firestore.dart';
Initialize the Firebase instance.
- final db = Firestore.instance;
To add a new student in students collection (we have created in Firestore).

kristian clomaPosted May 11, 2020, 7:18 AM
Hi Thanks for this po, but I cant find the children: generateStudentList(snapshot)