listBodyFrom<E> function

Result<List<E>> listBodyFrom<E>(
  1. String str
)

Implementation

Result<List<E>> listBodyFrom<E>(String str) {
  final body = json.decode(str) as Map<String, dynamic>;
  final list = body['data'] as List<dynamic>;
  final converter = _jsonConverters[E] as JsonDecoder<E>;
  final items = list.map(converter).toList(growable: false);
  return Result<List<E>>(
    items,
    code: body['code'] ?? -1,
  );
}