'The getter 'documents' isn't defined for the type 'Object' - Flutter Error
I am trying to read image URL from firebase fire store. But I am getting this error which says
"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' "
here is my code
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class FirebaseData extends StatelessWidget {
const FirebaseData({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder(
stream: FirebaseFirestore.instance.collection('cards').snapshots(),
builder: (context, snapshot) {
return ListView.builder(
itemCount: snapshot.data!.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot card = snapshot.data!.documents[index];
return Image.network(card['image']);
},
);
},
),
);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
