I need to show my firebase data in deference places. But in the same page. In every tutorial I followed they use Listview and I need to know there is another way to get data without using the list view
How to use get firebase data to StreamBuilder without Listview
882 views Asked by Dineth Siriwardana At
2
There are 2 answers
0
On
Expanded(
child: StreamBuilder(
stream:
FirebaseFirestore.instance.collection("posts").snapshots(),
builder: (context,
AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>>
snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
log(snapshot.data!.docs[index].data().toString());
return UserVideos(
snap: snapshot.data!.docs[index].data(),
);
},
);
}
log("${snapshot.stackTrace}stack trace");
log("${snapshot.error}error");
return const Text("Something went wrong");
},
),
),
Ya finally I think I found an answer