TorrentGetResponseParam.fromJson constructor

TorrentGetResponseParam.fromJson(
  1. dynamic rawData
)

Implementation

factory TorrentGetResponseParam.fromJson(rawData) {
  final rawRemoved = rawData["removed"];
  final rawTorrents = rawData["torrents"];
  final List<TorrentId> removed = rawRemoved is List
      ? rawRemoved.map((e) => TorrentId(id: (e as num).toInt())).toList()
      : const <TorrentId>[];
  final List<TorrentInfo> torrents = rawTorrents is List
      ? rawTorrents
          .whereType<JsonMap>()
          .map((e) => TorrentInfo.fromJson(e))
          .toList()
      : const <TorrentInfo>[];
  return TorrentGetResponseParam(torrents: torrents, removed: removed);
}