this is the code:...............
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Practice Firebase"),
),
body: StreamBuilder(
stream:
FirebaseFirestore.instance.collection("Animals").snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: const CircularProgressIndicator.adaptive(),
);
} else {
return ListView.builder(
itemCount: snapshot.data?.documents.length,
itemBuilder: (context, index) {
return ListTile(
title: snapshot.data.documents[index]["name"],
);
});
}
}));
}
}
The getter 'documents' isn't defined for the type 'Object'. Try importing the library that defines 'documents', correcting the name to the name of an existing getter, or defining a getter or field named 'documents'