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
Asked
Active
Viewed 682 times
0

Ken White
- 123,280
- 14
- 225
- 444

Dineth Siriwardana
- 75
- 5
-
1Instead of describing how you *don't* want to show the data, can you clarify how you **do** want to show it, or **why** you don't want to use a list view? – Frank van Puffelen Apr 17 '22 at 14:04
-
Most tutorials, like notes applications or getting transactions uses `ListView` not because it is the only medium, but because it is the best way to show that particular data. Flutter has many different ways of fetching data and a lot more ways of displaying it to the user. It all depends on what data you are trying to show and how you want to show it. – A.H.M. Annur Apr 17 '22 at 15:32
2 Answers
1
Ya finally I think I found an answer
final uid = FirebaseAuth.instance.currentUser!.uid;
userdata = FirebaseFirestore.instance.collection('/users/$uid/userdata');
return Scaffold(
body: StreamBuilder(
stream: userdata.snapshots(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Something went wrong');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Text("Loading");
}
try {
snapshot.data!.docs.map((DocumentSnapshot document) {
data = document.data()! as Map<String, dynamic>;
}).toList();
} catch (e) {
print(e.toString());
}
},
),
);

Dineth Siriwardana
- 75
- 5
0
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");
},
),
),

computer lap
- 1
- 1