CRUD APP
This app is truly for the beginners on firebase and flutter.
Initially create an account in firebase and connect the app to the firebase. You can read the tutorial here https://firebase.google.com/docs/android/setup
Firebase is one of the most popular BaaS used in mobile development. It offers a variety of services for mobile development, one of which we will be discussing in this article — Firebase Firestore. Firestore allows you to upload and retrieve data with very short and simple commands.
I have built this app to demonstrate Firestore CRUD ( Create Read Update Delete) operations.
We start by creating a Firebase project. If you need help creating a project on Firebase, you can check out this documentation that will guide you through that.
*Add the following packages to pubspec.yaml file:
Next, we initialize Firebase in our project
*Make your main function an async function and add these lines before the runApp() function:
*Import the required packages to the project.
When entering some inputs to the textfields such as NAME, STUDENTID, CGPA ,the input data are stored in the firestore(database).
*My firestore for the project
CREATE/WRITE
clicking on the create button will store all the inputs from the texfield to the firestore.
UPDATE
clicking on the update button will update the inputs.
DELETE
clicking on the delete button will eliminate the desired data from the firestore. Only 'Name'textfield is required to delete an element.
*At last we using a area where the stored data are display. used streambuilder to display data.StreamBuilder is a widget that builds itself based on the latest snapshot of interaction with a stream. This is mainly used in applications like chat application clock applications where the widget needs to rebuild itself to show the current snapshot of data.
*A DocumentReference refers to a document location in a FirebaseFirestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. A DocumentReference can also be used to create a CollectionReference to a subcollection.
*On line 279,given a textwidget when the database has no data to display which shows "EMPTY DATABASE".