I am was building a flutter application with some Sqflite and firestore database Now I have ran into a problem that whenever I run the application. I get snapshot.hasdata to true for the first time and than I get snapshot.hasdata to false in a second. I am attaching the screenshots of both console and the code here
StreamBuilder(
stream: FirebaseFirestore.instance
.collection('ADs CommonGroup')
.orderBy("id", descending: true)
.orderBy("id", descending: true)
.where('id', isEqualTo: databaseLogin[0]["number"])
.snapshots(),
builder: (
BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot,
) {
print('snapshot does not have data ${snapshot.hasData}');
print(databaseLogin[0]["number"]);
now the console prints this
I/flutter (16812): snapshot does not have data false
I/flutter (16812): +923335885631
I/flutter (16812): snapshot does not have data true
I/flutter (16812): +923335885631
I/flutter (16812): snapshot does not have data false
I/flutter (16812): +923335885631
What can I do code with Console
I think the snapshot.has data should return true as per the app was working like before
The first step when working with an
AsyncSnapshotis to handle errors. In a simple form:This will likely tell you the cause of the problem.