fromJson<V> static method

Future<PageableData<V>> fromJson<V>(
  1. Map<String, dynamic> map,
  2. StorageDecoder<V> decode
)

Converts PageableData from JSON. Used by storages that stores a value in JSON format.

Implementation

static Future<PageableData<V>> fromJson<V>(
  Map<String, dynamic> map,
  StorageDecoder<V> decode,
) async {
  final itemsMap = map['items'] as List<dynamic>;
  final items = await Stream.fromIterable(itemsMap).asyncMap(decode).toList();
  return PageableData<V>(
    loadedAll: map['loadedAll'] as bool,
    items: items,
    meta: map['meta'] as String?,
  );
}