loadEntities<T> method

Future<EntitiesResponse<T>> loadEntities<T>({
  1. required Uri uri,
  2. ApptiveGridLayout layout = ApptiveGridLayout.field,
  3. List<ApptiveGridSorting>? sorting,
  4. ApptiveGridFilter? filter,
  5. bool isRetry = false,
  6. Map<String, String> headers = const {},
  7. ApptiveGridHalVersion? halVersion,
  8. int? pageIndex,
  9. int? pageSize,
})

Load Entities of a Grid that are accessed by uri the layout in which the entities will be returned is determined by layout

sorting allows to apply custom sorting filter allows to get custom filters headers will be added in addition to ApptiveGridClient.defaultHeaders halVersion describes what Hal Version of ApptiveGrid should be used. This can effect the format and features of the response and might break parsing. pageIndex is the index of the page to be loaded. pageSize is the requested item count in the loaded page. Paging currently requires the header to contain 'accept': 'application/vnd.apptivegrid.hal'.

Implementation

Future<EntitiesResponse<T>> loadEntities<T>({
  required Uri uri,
  ApptiveGridLayout layout = ApptiveGridLayout.field,
  List<ApptiveGridSorting>? sorting,
  ApptiveGridFilter? filter,
  bool isRetry = false,
  Map<String, String> headers = const {},
  ApptiveGridHalVersion? halVersion,
  int? pageIndex,
  int? pageSize,
}) async {
  return (await performApptiveLink(
    link: ApptiveLink(uri: uri, method: 'get'),
    queryParameters: {
      'layout': layout.queryParameter,
      if (sorting != null)
        'sorting':
            jsonEncode(sorting.map((e) => e.toRequestObject()).toList()),
      if (filter != null) 'filter': jsonEncode(filter.toJson()),
      if (pageIndex != null) 'pageIndex': '$pageIndex',
      if (pageSize != null) 'pageSize': '$pageSize',
    },
    halVersion: halVersion,
    isRetry: isRetry,
    headers: headers,
    parseResponse: (response) async =>
        EntitiesResponse<T>.fromJson(jsonDecode(response.body)),
  ))!;
}