addTorrent method Null safety

Future<TorrentLight> addTorrent(
  1. {String? filename,
  2. String? metaInfo,
  3. String? downloadDir,
  4. String? cookies,
  5. bool? paused}

Add torrent to transmission filename optional filename or URL of the .torrent file metaInfo optional base64-encoded .torrent content downloadDir optional directory where to download the torrent cookies optional pointer to a string of one or more cookies paused optional boolean to paused the torrent when added Returns TorrentLight light torrent info if added successfully Throws AddTorrentException if errors


Future<TorrentLight> addTorrent({
  String? filename,
  String? metaInfo,
  String? downloadDir,
  String? cookies,
  bool? paused,
}) async {
  final results = await'/',
      data: _Request(methodAddTorrent, arguments: {
        if (filename != null) 'filename': filename,
        if (metaInfo != null) 'metainfo': metaInfo,
        if (downloadDir != null) 'download-dir': downloadDir,
        if (cookies != null) 'cookies': cookies,
        if (paused != null) 'paused': paused,
  final response = _Response.fromJSON(;
  if (response.isSuccess) {
    if (response.arguments!['torrent-duplicate'] != null) {
      throw AddTorrentException._(
          response.copyWith(result: 'Torrent duplicated'),
    } else {
      return TorrentLight._(response.arguments!['torrent-added']);
  } else {
    throw AddTorrentException._(
        response, TorrentLight._(response.arguments!['torrent-duplicate']));