I have been all over StackOverflow reading-related posts. However, I have yet to find one with a simple solution easy for a beginner such as myself to understand. Currently, my Cloud Firestore database looks like the following:
after the user has entered enough information to populate each of the fields in a document (ID is UID of an authenticated user via phone auth) then it gets sent into the database. Afterward, the user is redirected to the home screen where each of these fields should be displayed. This is where I am stuck. Below is a method I have started to implement that will return a string that will be inside a Text widget to display the username found inside the database.
String getUsername(FirebaseUser user, Firestore firestore) {
//get the document reference
DocumentReference docReference = firestore.document("Users/" + user.uid);
Future<DocumentSnapshot> snapshot = docReference.get();
Stream<DocumentSnapshot> stream = snapshot.asStream();
//stub to ignore compiler warnings
return null;
}
As you can see I'm fairly lost when it comes to using Futures and Streams. I have watched the videos on youtube by google flutter developers and they have helped me get up to this point. I also tried playing around with the then() and whenCompleted() methods offered by Future objects however I found myself digging a bigger and bigger hole.
All help is very much appreciated!
