I am using Firestore snapshots as a stream builder and loading widgets with listwiew builder. will it auto-paginate? does Flutter Firebase auto paginate with StremBuilder?
class twatter extends StatefulWidget {
const twatter({super.key});
@override
State<twatter> createState() => _twatterState();
}
class _twatterState extends State<twatter> {
Stream<QuerySnapshot<Map<String, dynamic>>>? stream;
@override
void initState() {
// TODO: implement initState
super.initState();
stream = FirebaseFirestore.instance
.collection('Apps')
.doc('Twatter')
.collection('userTweets')
.orderBy('time', descending: false)
.snapshots();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xff111218),
// backgroundColor: Color.fromARGB(255, 17, 17, 17),
body: SafeArea(
child: StreamBuilder(
stream: stream,
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
cacheExtent: 9999,
itemBuilder: (context, index) {
final post = snapshot.data!.docs[index];
return tweet(
postID: post.id,
tweetStr: post['tweetStr'],
userID: post['userID'],
nickName: post['nickname'],
time: "${post['time']}",
likes:
'${post['agree'].length + post['mid'].length + post['disagree'].length}',
comments: '200',
retweets: '1k',
greenPercentage: post['agree'],
yellowPercentage: post['mid'],
redPercentage: post['disagree'],
postImageUrl: post['postImageUrl'],
profileImageUrl: post['profileImageUrl'],
isVerified: true,
);
},
);
} else if (snapshot.hasError) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text('Error: ${snapshot.error}',
style:
TextStyle(color: Colors.white, fontFamily: 'retro')),
),
);
} else {
return CircularProgressIndicator();
}
},
),
),
);
}
}
i tried a lot of pagination methords but what i want is for the stream to auto update while also paginating. how do i do that ?