The return type 'StreamBuilder' isn't a 'QuerySnapshot<Object?>', as required by the closure's context.
I want to query a table and get the results after comparing them with another table, but when there are no results, it should return something empty, but it does not accept anything
If you want to return something empty when there are no results, you want something like this:
late Stream<QuerySnapshot<Map<String, dynamic>>> _stream;
_stream = //query that you are doing;
StreamBuilder(
stream: _stream,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.data!.isEmpty) {
return Center(
child: Text(
'Nothing!',
style: const TextStyle(fontSize: 20),
),
);
}
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (BuildContext context, int index) {
String name = snapshot['Name'];
return Text(name);
});
},