getRecentlyActive method Null safety

Future<RecentlyActiveTorrent> getRecentlyActive(
  1. {List<String> fields = const ['id', 'name', 'eta', 'queuePosition', 'downloadDir', 'isFinished', 'isStalled', 'leftUntilDone', 'metadataPercentComplete', 'error', 'errorString', 'percentDone', 'totalSize', 'peersConnected', 'sizeWhenDone', 'status', 'rateDownload', 'rateUpload', 'peersGettingFromUs', 'peersSendingToUs']}
)

Get recently torrents activity fields list of fields to retrieve Returns list of RecentlyActiveTorrent that contain removed torrent ids or torrents update info Throws TransmissionException if errors

Implementation

Future<RecentlyActiveTorrent> getRecentlyActive({
  List<String> fields = const [
    'id',
    'name',
    'eta',
    'queuePosition',
    'downloadDir',
    'isFinished',
    'isStalled',
    'leftUntilDone',
    'metadataPercentComplete',
    'error',
    'errorString',
    'percentDone',
    'totalSize',
    'peersConnected',
    'sizeWhenDone',
    'status',
    'rateDownload',
    'rateUpload',
    'peersGettingFromUs',
    'peersSendingToUs',
  ],
}) async {
  final results = await _dio.post('/',
      data: _Request(methodGetTorrent, arguments: {
        'fields': fields,
        'ids': 'recently-active',
      }).toJSON());
  final response = _Response.fromJSON(results.data);
  _checkResults(response);
  final torrentsData = response.arguments!['torrents'];
  final torrentsRemoved = response.arguments!['removed'];
  return RecentlyActiveTorrent(
    torrentsData
        .map((data) => Torrent._(data))
        .cast<Torrent>()
        .toList(growable: false),
    torrentsRemoved?.cast<int>(),
  );
}