docs: add infinite query page
This commit is contained in:
@@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.3/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]}],"date_created":"2022-09-15 12:05:12.417424","version":"3.3.0"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.3/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]}],"date_created":"2022-09-19 10:39:45.071010","version":"3.3.0"}
|
||||
@@ -37,9 +37,36 @@ class BasicInfiniteQueryExample extends StatelessWidget {
|
||||
return Stack(
|
||||
children: [
|
||||
ListView.builder(
|
||||
itemCount: infiniteQuery.pages.length,
|
||||
itemCount: infiniteQuery.pages.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
final page = infiniteQuery.pages[index];
|
||||
if (index == 0) {
|
||||
return Text(
|
||||
"""
|
||||
InfiniteQuery properties
|
||||
|
||||
isFetchingNextPage: ${infiniteQuery.isFetchingNextPage}
|
||||
isFetchingPreviousPage: ${infiniteQuery.isFetchingPreviousPage}
|
||||
isLoading: ${infiniteQuery.isLoading}
|
||||
isRefetching: ${infiniteQuery.isRefetching}
|
||||
isError: ${infiniteQuery.isError}
|
||||
isSuccess: ${infiniteQuery.isSuccess}
|
||||
isIdle: ${infiniteQuery.isIdle}
|
||||
isInactive: ${infiniteQuery.isInactive}
|
||||
isStale: ${infiniteQuery.isStale}
|
||||
fetched: ${infiniteQuery.fetched}
|
||||
|
||||
hasData: ${infiniteQuery.hasData}
|
||||
hasError: ${infiniteQuery.hasError}
|
||||
hasNextPage: ${infiniteQuery.hasNextPage}
|
||||
hasPreviousPage: ${infiniteQuery.hasPreviousPage}
|
||||
|
||||
refetchCount: ${infiniteQuery.refetchCount}
|
||||
retryAttempts: ${infiniteQuery.retryAttempts}
|
||||
updatedAt: ${infiniteQuery.updatedAt}
|
||||
""",
|
||||
);
|
||||
}
|
||||
final page = infiniteQuery.pages[index - 1];
|
||||
return ListTile(
|
||||
title: Text(page?["title"] ?? ""),
|
||||
subtitle: Text(page?["body"] ?? ""),
|
||||
|
||||
@@ -29,8 +29,8 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
|
||||
InfiniteQueryPageParamFunction<T, PageParam>? getNextPageParam;
|
||||
InfiniteQueryPageParamFunction<T, PageParam>? getPreviousPageParam;
|
||||
|
||||
bool _hasNextPage = false;
|
||||
bool _hasPreviousPage = false;
|
||||
bool _hasNextPage = true;
|
||||
bool _hasPreviousPage = true;
|
||||
|
||||
bool _isFetchingNextPage = false;
|
||||
bool _isFetchingPreviousPage = false;
|
||||
@@ -184,7 +184,7 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
|
||||
}
|
||||
|
||||
Future<List<T>> refetchPages([
|
||||
bool Function(T? page, int index, List<T?> allPages)? selector,
|
||||
bool Function(T? page, PageParam pageParam, List<T?> allPages)? selector,
|
||||
]) async {
|
||||
if (isFetchingNextPage ||
|
||||
isFetchingPreviousPage ||
|
||||
@@ -194,7 +194,7 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
|
||||
final queue = Queue();
|
||||
for (final entry in data?.entries.toList() ?? <MapEntry<PageParam, T?>>[]) {
|
||||
final page = entry.value;
|
||||
final selected = selector?.call(page, pages.indexOf(page), pages) ?? true;
|
||||
final selected = selector?.call(page, entry.key, pages) ?? true;
|
||||
if (!selected) continue;
|
||||
_currentParam = entry.key;
|
||||
queue.add<void>(
|
||||
|
||||
@@ -40,9 +40,36 @@ class BasicHookInfiniteQueryExample extends HookWidget {
|
||||
body: Stack(
|
||||
children: [
|
||||
ListView.builder(
|
||||
itemCount: infiniteQuery.pages.length,
|
||||
itemCount: infiniteQuery.pages.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
final page = infiniteQuery.pages[index];
|
||||
if (index == 0) {
|
||||
return Text(
|
||||
"""
|
||||
InfiniteQuery properties
|
||||
|
||||
isFetchingNextPage: ${infiniteQuery.isFetchingNextPage}
|
||||
isFetchingPreviousPage: ${infiniteQuery.isFetchingPreviousPage}
|
||||
isLoading: ${infiniteQuery.isLoading}
|
||||
isRefetching: ${infiniteQuery.isRefetching}
|
||||
isError: ${infiniteQuery.isError}
|
||||
isSuccess: ${infiniteQuery.isSuccess}
|
||||
isIdle: ${infiniteQuery.isIdle}
|
||||
isInactive: ${infiniteQuery.isInactive}
|
||||
isStale: ${infiniteQuery.isStale}
|
||||
fetched: ${infiniteQuery.fetched}
|
||||
|
||||
hasData: ${infiniteQuery.hasData}
|
||||
hasError: ${infiniteQuery.hasError}
|
||||
hasNextPage: ${infiniteQuery.hasNextPage}
|
||||
hasPreviousPage: ${infiniteQuery.hasPreviousPage}
|
||||
|
||||
refetchCount: ${infiniteQuery.refetchCount}
|
||||
retryAttempts: ${infiniteQuery.retryAttempts}
|
||||
updatedAt: ${infiniteQuery.updatedAt}
|
||||
""",
|
||||
);
|
||||
}
|
||||
final page = infiniteQuery.pages[index - 1];
|
||||
return ListTile(
|
||||
title: Text(page?["title"] ?? ""),
|
||||
subtitle: Text(page?["body"] ?? ""),
|
||||
|
||||
Reference in New Issue
Block a user