get method Null safety
Load association from SQLite first; if the _Model hasn't been loaded previously,
fetch it from remoteProvider and hydrate SQLite.
For available query providerArgs see remoteProvider#get SqliteProvider.get.
alwaysHydrate ensures data is fetched from the remoteProvider for each invocation.
This often negatively affects performance when enabled. Defaults to false.
hydrateUnexisting retrieves from the remoteProvider if the query returns no results from SQLite.
If an empty response can be expected (such as a search page), set to false. Defaults to true.
requireRemote ensures data must be updated from the remoteProvider before returning if the app is online.
An empty array will be returned if the app is offline. Defaults to false.
seedOnly does not load data from SQLite after inserting records. Association queries
can be expensive for large datasets, making deserialization a significant hit when the result
is ignorable (e.g. eager loading). Defaults to false.
Implementation
Future<List<T>?> get({
Query? query,
bool alwaysHydrate = false,
bool hydrateUnexisting = true,
bool requireRemote = false,
bool seedOnly = false,
}) async {
try {
await syncController.ready;
final List<T> result = await repository.get<T>(
query: query,
alwaysHydrate: alwaysHydrate || !hydrated,
hydrateUnexisting: hydrateUnexisting,
requireRemote: requireRemote,
seedOnly: seedOnly,
);
hydrated = true;
return result;
} on OfflineFirstException catch (err) {
_lastError = err;
state(SyncModelState.error);
return (err.originalError as RestException).response.throwError();
} on Exception catch (err) {
_lastError = err;
state(SyncModelState.error);
}
}