So, I'm facing this problem: the ' snapshot ' doesn't get any data from Firestore in StreamBuilder in Flutter.$
Here is the code:
StreamBuilder<Driver>(
initialData: null,
stream: DatabaseServices(uid: driver.uid).driverData,
builder: (streamContext, snapshot) {
print(driver.uid);
if (snapshot.hasData) {
Driver currentDriver = snapshot.data;
print(currentDriver.fullName);
print(currentDriver.email);
} else {
print('no data');
}
}
)
Note: stream: DatabaseServices(uid: driver.uid).driverData
-> driver here works fine on top of the whole code and gets the driver data such as uid.
And this code always returns ' no data '.
The weird thing here is that I'm using the same code (with another kind of user -> Client ) in another screen, and it works normally , and it gets the data properly .
And in Firestore, I have 2 collections, Driver and Clients , almost the same attributes.
It even has a SubCollection for both collections and it called ' Notification ', and I'm using a StreamBuilder to show the notifications for both Client and Driver and it works normally .
Problem solved, the problem was in some attribute that I called it with the wrong name that used in the other collection (Client), I forgot to change it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.