Я хотел бы разбить на страницы с FirebaseAnimatedList
, но я не знаю, как это сделать.
Я установил ScrollController
в свойство контроллера и смог получить уведомление при прокрутке вверх, но я не знаю, как получить дополнительные данные после этого.
Кто-нибудь знает, как разбивать на страницы?
Код:
int limit = 15;
@override
void initState() {
this.roomId = widget.roomId;
listScrollController = new ScrollController()..addListener(_listener);
super.initState();
}
_listener() {
if (listScrollController.position.pixels ==
listScrollController.position.maxScrollExtent) {
// fetch additional here
}
}
new Flexible(
child: new FirebaseAnimatedList(
controller: listScrollController,
query: FirebaseDatabase.instance
.reference()
.child('chat')
.child(roomId)
.limitToLast(limit),
padding: const EdgeInsets.all(8.0),
reverse: true,
sort: (a, b) => b.key.compareTo(a.key),
//comparing timestamp of messages to check which one would appear first
itemBuilder: (BuildContext context, DataSnapshot messageSnapshot,
Animation<double> animation, int index) {
return new ChatMessageListItem(
messageSnapshot: messageSnapshot,
animation: animation,
);
},
),
),