In my App, I need to get the Profile-Data of the current user before continuing. I try to accomplish this by using a StreamBuilder in my Code.
My Problem: The StreamBuilder always returns the else statement. As if he cannot load any data from the FireStore-Collection 'Users'.
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('Users').snapshots(), // It seems like he cannot load any data from the collection 'Users'...
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot){
if (snapshot.hasData) {
print("Loaded data successfully");
return Container(color: CupertinoColors.systemGreen,);
} else {
print("Could not load data");
return Container(color: CupertinoColors.systemRed,); // The Code always ends here
}
}
);
Furthermore I don't get any kind of Error-Message.
Flutter Doctor:
[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)• No issues found!
Why don't I get any data from Firestore?
EDIT:
My Firestore "Users" Collection (Sammlung):