这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ migrate_working_dir/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
*.lock
**/doc/api/
.dart_tool/
.packages
Expand Down
15 changes: 11 additions & 4 deletions lib/src/page_fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ class PageFetcher<Key, Value> extends ValueNotifier<PagingState<Key, Value>> {
log.fine('$loadType cancelled');
},
() async {
assert(
loadType != LoadType.refresh,
'Use doInitialLoad for LoadType == refresh',
);
// Ignore function call if pager is already loading
switch (loadType) {
case LoadType.append:
if (value.appendLoadState == const LoadState.loading()) return;

case LoadType.prepend:
if (value.prependLoadState == const LoadState.loading()) return;

case LoadType.refresh:
throw ArgumentError('Use doInitialLoad for LoadType == refresh');
}

final loadKey = _nextLoadKeyOrNull(loadType);
if (loadKey == null) return;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/widget/bidirectional_paging_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ class _BidirectionalPagingListViewState<Key, Value>

// Check if the index corresponds to near the top or bottom based on the
// 'reverse' flag.
final nearTop =
reverse ? index == itemCount - fetchIndex : index == fetchIndex;
final nearBottom =
reverse ? index == fetchIndex : index == itemCount - fetchIndex;
final nearUp = index <= fetchIndex;
final nearDown = index >= itemCount - fetchIndex;
final nearTop = reverse ? nearDown : nearUp;
final nearBottom = reverse ? nearUp : nearDown;

// Generate prepend notification.
if (nearTop) onBuildingPrependLoadTriggerItem?.call();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widget/paging_sliver_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ class _PagingSliverListState<Key, Value>
if (prefetchIndex == null) return;

// Generate prepend notification.
if (index == prefetchIndex) {
if (index <= prefetchIndex) {
onBuildingPrependLoadTriggerItem?.call();
}

// Generate append notification.
if (index == itemCount - prefetchIndex) {
if (index >= itemCount - prefetchIndex) {
onBuildingAppendLoadTriggerItem?.call();
}
}
Expand Down