|
...
|
...
|
@@ -43,6 +43,7 @@ class _ContactListPageState extends State<ContactListPage> { |
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
widget.provider.handleList(widget.contacts);
|
|
|
|
|
|
|
|
positon.itemPositions.addListener(_itemPositonChanaged
|
|
|
|
// print('${positon.itemPositions.value.last.index}');
|
|
|
|
// // positon.itemPositions.value
|
|
...
|
...
|
@@ -64,15 +65,26 @@ class _ContactListPageState extends State<ContactListPage> { |
|
|
|
_itemPositonChanaged() {
|
|
|
|
// ItemPosition itemPosition = positon.itemPositions.value.first;
|
|
|
|
print('${positon.itemPositions.value.last.index}');
|
|
|
|
// positon.itemPositions.value
|
|
|
|
if (positon.itemPositions.value.last.index == 1 &&
|
|
|
|
widget.contacts.length >= 10) {
|
|
|
|
|
|
|
|
int max = positon.itemPositions.value
|
|
|
|
.where((ItemPosition position) => position.itemLeadingEdge < 1)
|
|
|
|
.reduce((ItemPosition max, ItemPosition position) =>
|
|
|
|
position.itemLeadingEdge > max.itemLeadingEdge ? position : max)
|
|
|
|
.index;
|
|
|
|
int min = positon.itemPositions.value
|
|
|
|
.where((ItemPosition position) => position.itemTrailingEdge > 0)
|
|
|
|
.reduce((ItemPosition min, ItemPosition position) =>
|
|
|
|
position.itemTrailingEdge < min.itemTrailingEdge ? position : min)
|
|
|
|
.index;
|
|
|
|
print(min);
|
|
|
|
print(max);
|
|
|
|
if (min == 0 && widget.contacts.length > 10) {
|
|
|
|
bus.emit(
|
|
|
|
'onrefresh_guest_list',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (positon.itemPositions.value.last.index == widget.contacts.length - 1 &&
|
|
|
|
widget.contacts.length >= 10) {
|
|
|
|
|
|
|
|
if (max == widget.contacts.length - 1 && widget.contacts.length >= 10) {
|
|
|
|
//上拉加载方法,最底部
|
|
|
|
|
|
|
|
bus.emit(
|
|
...
|
...
|
@@ -81,6 +93,24 @@ class _ContactListPageState extends State<ContactListPage> { |
|
|
|
? 1
|
|
|
|
: (widget.contacts.length / 10).toInt());
|
|
|
|
}
|
|
|
|
// positon.itemPositions.value
|
|
|
|
// if (positon.itemPositions.value.last.index == 1 &&
|
|
|
|
// widget.contacts.length >= 10) {
|
|
|
|
// bus.emit(
|
|
|
|
// 'onrefresh_guest_list',
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (positon.itemPositions.value.last.index == widget.contacts.length - 1 &&
|
|
|
|
// widget.contacts.length >= 10) {
|
|
|
|
// //上拉加载方法,最底部
|
|
|
|
|
|
|
|
// bus.emit(
|
|
|
|
// 'onload_guest_list',
|
|
|
|
// (widget.contacts.length / 10) < 1
|
|
|
|
// ? 1
|
|
|
|
// : (widget.contacts.length / 10).toInt());
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
// void loadData() async {
|
...
|
...
|
|