GridResult<TListItem>.fromMap constructor
GridResult<TListItem>.fromMap(
- Map map, [
- TListItem itemParser(
- Map<String, dynamic> data
)?
])
Implementation
factory GridResult.fromMap(Map<dynamic, dynamic> map,
[TListItem Function(Map<String, dynamic> data)? itemParser]) {
final List<TListItem> items = map[GridResultJsonConfiguration.itemsJsonKey]
?.map<TListItem>((x) => itemParser?.call(x) ?? x as TListItem)
.toList() ??
[];
final int pageSize = map[GridResultJsonConfiguration.pageSizeJsonKey] ?? 0;
return GridResult<TListItem>(
items: items,
hasMoreItems: map[GridResultJsonConfiguration.hasMoreItemsJsonKey] ??
items.count == pageSize,
currentPage: map[GridResultJsonConfiguration.currentPageJsonKey] ?? 0,
startPage: map[GridResultJsonConfiguration.startPageJsonKey] ?? 0,
endPage: map[GridResultJsonConfiguration.endPageJsonKey] ?? 0,
pageCount: map[GridResultJsonConfiguration.pageCountJsonKey] ?? 0,
pageSize: pageSize,
rowCount: map[GridResultJsonConfiguration.rowCountJsonKey] ?? 0,
hasPreviousPage:
map[GridResultJsonConfiguration.hasPreviousPageJsonKey] ?? 0,
hasNextPage: map[GridResultJsonConfiguration.hasNextPageJsonKey] ?? 0,
hasMultiplePages:
map[GridResultJsonConfiguration.hasMultiplePagesJsonKey] ?? 0,
firstRowOnPage:
map[GridResultJsonConfiguration.firstRowOnPageJsonKey] ?? 0,
lastRowOnPage: map[GridResultJsonConfiguration.lastRowOnPageJsonKey] ?? 0,
hasItems: map[GridResultJsonConfiguration.hasItemsJsonKey] ??
items.isNotNullOrEmpty,
additionalData: map[GridResultJsonConfiguration.additionalDataJsonKey],
);
}