feat(infinite-query): add refetchPages, refetchOnStale, refetchOnMount support

This commit is contained in:
Kingkor Roy Tirtho
2022-09-14 12:49:30 +06:00
parent 61958c7d94
commit 95b1837620
20 changed files with 257 additions and 104 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
# This is a generated file; do not edit or check into version control.
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.5/
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/
connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.2/
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.3/
connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
@@ -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.5/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.5/","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.2/","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-08-24 21:03:29.720419","version":"3.0.5"}
{"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+1/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/","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-14 11:35:43.874010","version":"3.3.0"}
@@ -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-08-24 21:03:52.762936","version":"3.0.5"}
{"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-14 11:35:53.826188","version":"3.3.0"}
@@ -1,2 +1,5 @@
sdk.dir=/opt/android-sdk
flutter.sdk=/home/krtirtho/fvm/versions/3.0.5
sdk.dir=/home/krtirtho/Android/Sdk
flutter.sdk=/opt/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
@@ -1,7 +1,6 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:fl_query/fl_query.dart';
import 'package:http/http.dart' as http;
@@ -49,9 +48,18 @@ class BasicInfiniteQueryExample extends StatelessWidget {
),
Align(
alignment: Alignment.bottomRight,
child: IconButton(
icon: const Icon(Icons.get_app_rounded),
onPressed: () => infiniteQuery.fetchNextPage(),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.refresh_rounded),
onPressed: () => infiniteQuery.refetchPages(),
),
IconButton(
icon: const Icon(Icons.get_app_rounded),
onPressed: () => infiniteQuery.fetchNextPage(),
),
],
),
),
],
@@ -1,10 +1,16 @@
# Generated code do not commit.
file(TO_CMAKE_PATH "/home/krtirtho/fvm/versions/3.0.5" FLUTTER_ROOT)
file(TO_CMAKE_PATH "/opt/flutter" FLUTTER_ROOT)
file(TO_CMAKE_PATH "/home/krtirtho/dev/fl-query/packages/fl_query/example" PROJECT_DIR)
set(FLUTTER_VERSION "1.0.0+1" PARENT_SCOPE)
set(FLUTTER_VERSION_MAJOR 1 PARENT_SCOPE)
set(FLUTTER_VERSION_MINOR 0 PARENT_SCOPE)
set(FLUTTER_VERSION_PATCH 0 PARENT_SCOPE)
set(FLUTTER_VERSION_BUILD 1 PARENT_SCOPE)
# Environment variables to pass to tool_backend.sh
list(APPEND FLUTTER_TOOL_ENVIRONMENT
"FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.0.5"
"FLUTTER_ROOT=/opt/flutter"
"PROJECT_DIR=/home/krtirtho/dev/fl-query/packages/fl_query/example"
"DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
"DART_OBFUSCATION=false"
+19 -19
View File
@@ -14,7 +14,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
@@ -28,21 +28,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
@@ -119,7 +112,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
@@ -197,21 +190,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
nm:
dependency: transitive
description:
@@ -225,7 +218,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
petitparser:
dependency: transitive
description:
@@ -240,6 +233,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
queue:
dependency: transitive
description:
name: queue
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0+1"
sky_engine:
dependency: transitive
description: flutter
@@ -258,7 +258,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
@@ -279,21 +279,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
typed_data:
dependency: transitive
description:
+6 -12
View File
@@ -71,7 +71,7 @@ abstract class BaseQuery<T extends Object, Outside, Error>
if (onError != null) _onErrorListeners.add(onError);
if (refetchInterval != null && refetchInterval != Duration.zero) {
_refetchIntervalTimer = _createRefetchTimer();
_refetchIntervalTimer = createRefetchTimer();
}
}
// all getters & setters
@@ -79,16 +79,8 @@ abstract class BaseQuery<T extends Object, Outside, Error>
Outside get externalData => _externalData;
Outside? get prevUsedExternalData => _prevUsedExternalData;
Timer _createRefetchTimer() {
return Timer.periodic(
refetchInterval!,
(_) async {
// only refetch if its connected to the internet or refetch will
// always result in error while there's no internet
if (isStale && await isInternetConnected()) await refetch();
},
);
}
@protected
Timer createRefetchTimer();
/// Calls the task function & doesn't check if there's already
/// cached data available
@@ -205,7 +197,9 @@ abstract class BaseQuery<T extends Object, Outside, Error>
return await execute().then((_) => data);
}
@protected
FutureOr<void> setData();
@protected
void setError(dynamic);
/// Sets the [externalData] from outside of the query
@@ -251,7 +245,7 @@ abstract class BaseQuery<T extends Object, Outside, Error>
refetchInterval != Duration.zero) {
this.refetchInterval = refetchInterval;
_refetchIntervalTimer?.cancel();
_refetchIntervalTimer = _createRefetchTimer();
_refetchIntervalTimer = createRefetchTimer();
}
if (this.cacheTime == Duration(minutes: 5) && cacheTime != null)
this.cacheTime = cacheTime;
+62 -3
View File
@@ -4,6 +4,8 @@ import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:fl_query/src/base_query.dart';
import 'package:fl_query/src/models/infinite_query_job.dart';
import 'package:fl_query/src/query.dart';
import 'package:flutter/cupertino.dart';
import 'package:queue/queue.dart';
typedef InfiniteQueryTaskFunction<T extends Object, Outside,
PageParam extends Object>
@@ -91,6 +93,19 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
List<dynamic> get errors => error?.values.toList() ?? [];
List<T?> get pages => data?.values.toList() ?? [];
@override
@protected
Timer createRefetchTimer() {
return Timer.periodic(
refetchInterval!,
(_) async {
// only refetch if its connected to the internet or refetch will
// always result in error while there's no internet
if (isStale && await isInternetConnected()) await refetchPages();
},
);
}
Future<T?> fetchNextPage([
InfiniteQueryPageParamFunction<T, PageParam>? getNextPageParam,
]) async {
@@ -110,10 +125,11 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
_hasNextPage = false;
notifyListeners();
return null;
} else {
_hasNextPage = true;
_currentParam = nextParam;
return await refetch().then((data) => data?[_currentParam]);
}
_hasNextPage = true;
_currentParam = nextParam;
return await refetch().then((data) => data?[_currentParam]);
} finally {
_isFetchingNextPage = false;
notifyListeners();
@@ -154,11 +170,53 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
}
}
Future<List<T>> refetchPages([
bool Function(T? page, int index, List<T?> allPages)? selector,
]) async {
if (isFetchingNextPage ||
isFetchingPreviousPage ||
isLoading ||
isRefetching) return [];
final refetchedPages = <T>[];
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;
if (!selected) continue;
_currentParam = entry.key;
queue.add<void>(
() async {
final s = await refetch();
if (s?[_currentParam] != null) {
refetchedPages.add(s![_currentParam]!);
}
},
);
}
await queue.onComplete;
return refetchedPages;
}
@override
// TODO: implement debugLabel
String get debugLabel => "InfiniteQuery($queryKey)";
@override
void mount(ValueKey<String> uKey) {
super.mount(uKey);
/// refetching on mount if it's set to true
/// also checking if the is stale or not
/// no need to refetch a valid query for no reason
if (refetchOnMount == true && isStale) {
this.isInternetConnected().then((isConnected) async {
if (isConnected) await refetchPages();
});
}
}
@override
@protected
void setData() async {
if (data == null) data = Map();
data?[_currentParam] = await task(
@@ -169,6 +227,7 @@ class InfiniteQuery<T extends Object, Outside, PageParam extends Object>
}
@override
@protected
void setError(specError) {
if (error is! Map) error = Map();
error?[_currentParam] = specError;
@@ -48,14 +48,77 @@ class _InfiniteQueryBuilderState<T extends Object, Outside,
final hasExternalDataChanged = infiniteQuery!.externalData != null &&
infiniteQuery!.prevUsedExternalData != null &&
!isShallowEqual(
infiniteQuery!.externalData!, infiniteQuery!.prevUsedExternalData!);
infiniteQuery!.externalData!,
infiniteQuery!.prevUsedExternalData!,
);
if (infiniteQuery!.fetched && hasExternalDataChanged) {
await infiniteQuery!.refetch();
await infiniteQuery!.refetchPages();
} else if (!infiniteQuery!.fetched) {
await infiniteQuery!.fetch();
}
}
@override
void didUpdateWidget(covariant oldWidget) {
// final hasOnErrorChanged = false;
// oldWidget.onError != widget.onError && oldWidget.onError != null;
// final hasOnDataChanged = false;
// oldWidget.onData != widget.onData && oldWidget.onData != null;
// re-init the query-builder when new queryJob is appended
if (oldWidget.job.queryKey != widget.job.queryKey) {
_infiniteQueryDispose();
init();
/// setting the new query's initial data as prev query's data
/// when [job.keepPreviousData] is true and both are dynamic
// if (oldWidget.job.isDynamic &&
// widget.job.isDynamic &&
// oldWidget.job.keepPreviousData == true &&
// widget.job.keepPreviousData == true) {
// init(infiniteQuery?.pages);
// } else {
// init();
// }
} else if (oldWidget.externalData != null &&
widget.externalData != null &&
!isShallowEqual(oldWidget.externalData!, widget.externalData!)) {
if (widget.job.refetchOnExternalDataChange ??
queryBowl.refetchOnExternalDataChange) {
QueryBowl.of(context).addInfiniteQuery(
widget.job,
externalData: widget.externalData,
key: uKey,
// onData: widget.onData,
// onError: widget.onError,
)..refetchPages();
} else {
QueryBowl.of(context)
.getQuery(widget.job.queryKey)
?.setExternalData(widget.externalData);
}
// if (hasOnDataChanged) query?.removeDataListener(oldWidget.onData!);
// if (hasOnErrorChanged) query?.removeErrorListener(oldWidget.onError!);
} else {
// if (hasOnDataChanged) {
// query?.removeDataListener(oldWidget.onData!);
// if (widget.onData != null) query?.addDataListener(widget.onData!);
// }
// if (hasOnErrorChanged) {
// query?.removeErrorListener(oldWidget.onError!);
// if (widget.onError != null) query?.addErrorListener(widget.onError!);
// }
}
super.didUpdateWidget(oldWidget);
}
_infiniteQueryDispose() {
infiniteQuery?.unmount(uKey);
// if (widget.onData != null) query?.removeDataListener(widget.onData!);
// if (widget.onError != null) query?.removeErrorListener(widget.onError!);
}
@override
Widget build(BuildContext context) {
queryBowl = QueryBowl.of(context);
+12
View File
@@ -85,6 +85,18 @@ class Query<T extends Object, Outside> extends BaseQuery<T, Outside, dynamic> {
queryKey: options.queryKey,
);
@override
Timer createRefetchTimer() {
return Timer.periodic(
refetchInterval!,
(_) async {
// only refetch if its connected to the internet or refetch will
// always result in error while there's no internet
if (isStale && await isInternetConnected()) await refetch();
},
);
}
/// can be used to update the data manually. Can be useful when used
/// together with mutations to perform optimistic updates or manual data
/// updates
+36 -33
View File
@@ -114,6 +114,12 @@ class _QueryBowlScopeState extends State<QueryBowlScope> {
await query.refetch();
await Future.delayed(widget.refetchOnReconnectDelay);
}
for (final infiniteQuery in infiniteQueries) {
if (infiniteQuery.refetchOnReconnect == false ||
!infiniteQuery.enabled) continue;
await infiniteQuery.refetchPages();
await Future.delayed(widget.refetchOnReconnectDelay);
}
}
});
}
@@ -169,10 +175,10 @@ class _QueryBowlScopeState extends State<QueryBowlScope> {
// basically garbage collecting queries
setState(() {
infiniteQueries = Set.from(
// infiniteQuery.isInactive
// ? infiniteQueries.where((el) => el.queryKey != infiniteQuery.queryKey)
// : infiniteQuery,
infiniteQueries,
infiniteQuery.isInactive
? infiniteQueries
.where((el) => el.queryKey != infiniteQuery.queryKey)
: infiniteQueries,
);
});
});
@@ -350,25 +356,25 @@ class QueryBowl extends InheritedWidget {
return query;
}
// InfiniteQuery<T, Outside, PageParam> _createInfiniteQueryWithDefaults<
// T extends Object, Outside, PageParam extends Object>(
// InfiniteQueryJob<T, Outside, PageParam> options,
// Outside externalData,
// ) {
// final query = InfiniteQuery<T, Outside, PageParam>.fromOptions(
// options,
// externalData: externalData,
// queryBowl: this,
// );
// query.updateDefaultOptions(
// cacheTime: cacheTime,
// staleTime: staleTime,
// refetchInterval: refetchInterval,
// refetchOnMount: refetchOnMount,
// refetchOnReconnect: refetchOnReconnect,
// );
// return query;
// }
InfiniteQuery<T, Outside, PageParam> _createInfiniteQueryWithDefaults<
T extends Object, Outside, PageParam extends Object>(
InfiniteQueryJob<T, Outside, PageParam> options,
Outside externalData,
) {
final infiniteQuery = InfiniteQuery<T, Outside, PageParam>.fromOptions(
options,
externalData: externalData,
queryBowl: this,
);
infiniteQuery.updateDefaultOptions(
cacheTime: cacheTime,
staleTime: staleTime,
refetchInterval: refetchInterval,
refetchOnMount: refetchOnMount,
refetchOnReconnect: refetchOnReconnect,
);
return infiniteQuery;
}
Future<T?> prefetchQuery<T extends Object, Outside>(
QueryJob<T, Outside> options, {
@@ -451,18 +457,15 @@ class QueryBowl extends InheritedWidget {
// mounting the widget that is using the query in the prevQuery
return prevInfiniteQuery;
}
// _createQueryWithDefaults<T, Outside, PageParam>(
// infiniteQueryJob,
// externalData,
// );
final infiniteQuery = InfiniteQuery<T, Outside, PageParam>.fromOptions(
final infiniteQuery =
_createInfiniteQueryWithDefaults<T, Outside, PageParam>(
infiniteQueryJob,
externalData: externalData,
queryBowl: this,
externalData,
);
// if (onData != null) infiniteQuery.addDataListener(onData);
// if (onError != null) infiniteQuery.addErrorListener(onError);
// infiniteQuery.mount(key);
if (onData != null) infiniteQuery.addDataListener(onData);
if (onError != null) infiniteQuery.addErrorListener(onError);
infiniteQuery.mount(key);
_addInfiniteQuery<T, Outside, PageParam>(infiniteQuery);
return infiniteQuery;
}
+5 -1
View File
@@ -57,7 +57,11 @@ class _QueryBuilderState<T extends Object, Outside>
);
final hasExternalDataChanged = query!.externalData != null &&
query!.prevUsedExternalData != null &&
!isShallowEqual(query!.externalData!, query!.prevUsedExternalData!);
!isShallowEqual(
query!.externalData!,
query!.prevUsedExternalData!,
);
if (query!.fetched && hasExternalDataChanged) {
await query!.refetch();
} else if (!query!.fetched) {
+1
View File
@@ -17,6 +17,7 @@ dependencies:
connectivity_plus: ^2.3.5
flutter:
sdk: flutter
queue: ^3.1.0+1
uuid: ^3.0.6
dev_dependencies:
+1 -1
View File
@@ -1,5 +1,5 @@
# This is a generated file; do not edit or check into version control.
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6/
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/
connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.3/
@@ -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-08-16 21:50:27.976582","version":"3.0.5"}
{"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+1/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/","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-14 11:35:42.984387","version":"3.3.0"}
@@ -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-08-16 21:50:30.683860","version":"3.0.5"}
{"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-14 11:35:47.051873","version":"3.3.0"}
+19 -19
View File
@@ -14,7 +14,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
@@ -28,21 +28,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
@@ -119,7 +112,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
@@ -204,21 +197,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
nm:
dependency: transitive
description:
@@ -232,7 +225,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
petitparser:
dependency: transitive
description:
@@ -247,6 +240,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
queue:
dependency: transitive
description:
name: queue
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0+1"
sky_engine:
dependency: transitive
description: flutter
@@ -258,7 +258,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
@@ -279,21 +279,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
typed_data:
dependency: transitive
description: