The following NoSuchMethodError was thrown building: Class 'QuerySnapshot' has no instance method 'call'. Receiver: Instance of 'QuerySnapshot' Tried calling: call()
When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) #1 _HomekitchenListState.build.. (package:pigeon/cook_pages/homekitchen_listpage.dart:26:62) #2 SliverChildBuilderDelegate.build (package:flutter/src/widgets/sliver.dart:449:22) #3 SliverMultiBoxAdaptorElement._build (package:flutter/src/widgets/sliver.dart:1130:28) #4 SliverMultiBoxAdaptorElement.createChild. (package:flutter/src/widgets/sliver.dart:1143:55)
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:provider/provider.dart';
class HomekitchenList extends StatefulWidget {
@override
_HomekitchenListState createState() => _HomekitchenListState();
}
class _HomekitchenListState extends State<HomekitchenList> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder(
stream:
FirebaseFirestore.instance.collection("Homekitchens").snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
print("snapshot from homecooks doesnt have any data");
return Text(
"snapshot from homecooks doesnt have any data"); //replace with popup in future
} else {
return ListView.builder(
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index) {
DocumentSnapshot homekitchens = snapshot.data().docs[index];
print(homekitchens);
//var homekitchens= kitchencollection.data()[index];
return Padding(
padding:
const EdgeInsets.symmetric(horizontal: 13, vertical: 8),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
// ignore: missing_return, missing_return, missing_return, missing_return
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
),
child: Container(
width: MediaQuery.of(context).size.width,
height: 100,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20)),
),
child: Text(
"${homekitchens.id}",
style: TextStyle(
fontFamily: "Comfortaa",
// ignore: missing_return
fontSize: 30),
),
),
),
);
},
);
}
},
),
);
}
}
DocumentSnapshot homekitchens = snapshot.data().docs[index];
- heredata()
should be changed todata
. – Muthu Thavamani