Skip to content

Commit

Permalink
chore: add package_demo.gif
Browse files Browse the repository at this point in the history
Signed-off-by: Sahil Kumar <xdsahil@gmail.com>
  • Loading branch information
xsahil03x committed Feb 7, 2024
1 parent a8bf9c7 commit 1503769
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Live Demo: https://xsahil03x.github.io/super_pager
**Show some ❤️ and star the repo to support the project**

<p>
<img src="https://github.com/xsahil03x/multi_trigger_autocomplete/blob/master/asset/package_demo.gif?raw=true" alt="An animated image of the MultiTriggerAutocomplete" height="400"/>
<img src="https://github.com/xsahil03x/super_pager/blob/master/asset/package_demo.gif?raw=true" alt="An animated image of the SuperPager" height="400"/>
</p>

## Features
Expand Down
Binary file added asset/package_demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions lib/src/page_fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class PageFetcher<Key, Value> extends ValueNotifier<PagingState<Key, Value>> {
final params = _loadParams(loadType, loadKey);

log.fine(
'Start $loadType with loadKey $loadKey on $pagingSource in ${describeIdentity(this)}');
'Start $loadType with loadKey $loadKey on $pagingSource in ${describeIdentity(this)}',
);

final result = await _withCancellationScope(
token: _cancellationToken,
Expand Down Expand Up @@ -203,17 +204,18 @@ class PageFetcher<Key, Value> extends ValueNotifier<PagingState<Key, Value>> {
if (pagesToDropCount <= 0) return;

log.fine(
'Dropping $pagesToDropCount pages for $dropType in ${describeIdentity(this)}');
'Dropping $pagesToDropCount pages for $dropType in ${describeIdentity(this)}',
);

// Drop pages.
value = value.dropPages(dropType, pageCount: pagesToDropCount);
},
);
}

// @return [PageEvent.Drop] for [loadType] that would allow this [PageFetcher] to
// respect [PagingConfig.maxSize], `null` if no pages should be dropped for the provided
// [loadType].
/// Returns number of pages to drop for [loadType] that would allow this
/// [PageFetcher] to respect [PagingConfig.maxSize], `0` if no pages should be
/// dropped for the provided [loadType].
int _pagesToDropCount(LoadType loadType) {
final maxSize = config.maxSize;
if (maxSize == null) return 0;
Expand Down Expand Up @@ -250,6 +252,8 @@ class PageFetcher<Key, Value> extends ValueNotifier<PagingState<Key, Value>> {
return pagesToDrop;
}

/// Returns the key to use to load the next page for the given [loadType] or
/// null if we should stop loading in this direction.
Key? _nextLoadKeyOrNull(LoadType loadType) {
return switch (loadType) {
LoadType.prepend => _nextPrependKey,
Expand All @@ -258,8 +262,8 @@ class PageFetcher<Key, Value> extends ValueNotifier<PagingState<Key, Value>> {
};
}

// The key to use to load next page to prepend or null if we should stop
// loading in this direction.
/// The key to use to load next page to prepend or null if we should stop
/// loading in this direction.
Key? get _nextPrependKey {
final currentValue = value;
if (currentValue.pages.isEmpty) return null;
Expand All @@ -269,8 +273,8 @@ class PageFetcher<Key, Value> extends ValueNotifier<PagingState<Key, Value>> {
return currentValue.pages.first.prevKey;
}

// The key to use to load next page to append or null if we should stop
// loading in this direction.
/// The key to use to load next page to append or null if we should stop
/// loading in this direction.
Key? get _nextAppendKey {
final currentValue = value;
if (currentValue.pages.isEmpty) return null;
Expand Down

0 comments on commit 1503769

Please sign in to comment.