searchSongs static method

Future<List<Song>> searchSongs({
  1. String? query,
  2. String? artistId,
  3. required int limit,
  4. required int page,
})

Implementation

static Future<List<Song>> searchSongs({
  String? query,
  String? artistId,
  required int limit,
  required int page,
}) async {
  final jsonString = await _channel.invokeMethod<String>('searchSongs', {
    if (query != null) 'query': query,
    if (artistId != null) 'artistId': artistId,
    'limit': limit,
    'page': page,
  });

  if (jsonString == null) {
    throw PlatformException(code: 'NULL_RESPONSE');
  }

  final jsonObject = json.decode(jsonString) as List<dynamic>;
  return jsonObject.map(Song.fromJson).toList(growable: false);
}