loadGrid method
Future<Grid>
loadGrid({
- required Uri uri,
- List<
ApptiveGridSorting> ? sorting, - ApptiveGridFilter? filter,
- bool isRetry = false,
- Map<
String, String> headers = const {}, - bool loadEntities = true,
Loads a Grid represented by gridUri
sorting
defines the order in which items will be returned
The order of ApptiveGridSorting in sorting
will rank the order in which values should be sorted
headers
will be added in addition to ApptiveGridClient.defaultHeaders
If loadEntities
is true
and there is a ApptiveLinkType.entities Link it will also fetch the entities
Requires Authorization
throws Response
if the request fails
Implementation
Future<Grid> loadGrid({
required Uri uri,
List<ApptiveGridSorting>? sorting,
ApptiveGridFilter? filter,
bool isRetry = false,
Map<String, String> headers = const {},
bool loadEntities = true,
}) async {
final gridViewResponse = await performApptiveLink<http.Response>(
link: ApptiveLink(uri: uri, method: 'get'),
headers: headers,
halVersion: ApptiveGridHalVersion.v2,
isRetry: isRetry,
parseResponse: (response) async => response,
);
final gridToParse = jsonDecode(gridViewResponse!.body);
final grid = Grid.fromJson(gridToParse);
if (loadEntities && grid.links.containsKey(ApptiveLinkType.entities)) {
final entitiesResponse = await this.loadEntities(
uri: grid.links[ApptiveLinkType.entities]!.uri,
layout: ApptiveGridLayout.indexed,
filter: filter,
sorting: sorting,
);
final entities = entitiesResponse.items;
gridToParse['entities'] = entities;
return Grid.fromJson(gridToParse);
} else {
return grid;
}
}