we are making home page like Instagram and I want to show only the user post for now. the code was like this
StreamBuilder(
stream: FirebaseFirestore.instance.collection('posts').orderBy("datePublished", descending: true).snapshots(),
builder: (context,
AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
return PageView.builder(/*the rest of the code ...*/);
it worked but it shows all the post so I added this
.where('uid', isEqualTo: uid)
and it looks like this inside Widget build
var uid = FirebaseAuth.instance.currentUser!.uid;
inside body like this
StreamBuilder(
stream: FirebaseFirestore.instance.collection('posts').where('uid', isEqualTo: uid).orderBy("datePublished", descending: true).snapshots(),
builder: (context,
AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
return PageView.builder( //to make the page scroll
itemCount: snapshot.data!.docs.length,/*the rest of the code*/);
and it shows an error in line
itemCount: snapshot.data!.docs.length, saying
Null check operator used on a null value
the database look like this