Listening for Data from Firebase using Streams

preview_player
Показать описание
Listening for Data from Firebase using Streams

This lesson teaches how to retrieve data from a database and use it to populate an app. It involves creating a new method called get messages, which goes into the Firebase Cloud Firestore and calls the get documents method. This method returns a future query snapshot, which is a data type from Firebase. If desired, the data can be saved as a final and marked with async. The most important details in this text are how to create a for-loop for looping through a list of document snapshots.

To do this, a new variable is created called var message in messages dot document, and a for loop is created to loop through the list and print the document snapshot dot data. Finally, a button is created to trigger the method, and the message is printed inside the console. The code currently works by getting a hold of all the documents in a messages collection and creating a single message out of them. However, if a new document is added, the sender and text fields are left blank and the data associated with it is pulled out of the database. To achieve this, a different approach is needed, which involves creating a method called messages stream, which is an asynchronous method that does not take inputs but is also an asynchronous method. This method would allow the data to be pushed to the app when new data is added by the conversation partner or someone else who has the app installed.

THANKS FOR WATCHING AND DON'T FORGET TO LIKE, COMMENT, SUBSCRIBE, AND HIT THE BELL ICON TO WATCH THE LATEST VIDEO!

#edudreams #Flutter#dart#flutterdev

-~-~~-~~~-~~-~-
Please watch: "String manipulation in Python #codingtutorial #python #programminglanguage #coding"
-~-~~-~~~-~~-~-
Рекомендации по теме