querySongsBy method

Future<List<SongModel>> querySongsBy(
  1. SongsByType songsByType,
  2. List<Object> values, [
  3. UriType? uriType,
  4. bool? requestPermission,
])

Used to return Songs Info based in SongModel.

This method will search every single music based in some value from SongsByType.

Parameters:

  • requestPermission is used for request or no Android STORAGE PERMISSION.
  • songsByType is used to define a value that will be used to find the music.
  • uriType is used to define if songs will be catch in EXTERNAL or INTERNAL storage.
  • values is used to define the value to find every music.

Important:

  • If requestPermission is null, will be set to false.
  • If uriType is null, will be set to EXTERNAL.

Implementation

Future<List<SongModel>> querySongsBy(
  SongsByType songsByType,
  List<Object> values, [
  UriType? uriType,
  bool? requestPermission,
]) async {
  List<String> valuesConverted = [];
  values.forEach((element) {
    valuesConverted.add(element.toString());
  });
  final List<dynamic> resultSongs =
      await _channel.invokeMethod("querySongsBy", {
    "requestPermission": _checkPermission(requestPermission),
    "by": songsByType.index,
    "uri": uriType != null ? uriType.index : UriType.EXTERNAL.index,
    "values": valuesConverted
  });
  return resultSongs.map((songInfo) => SongModel(songInfo)).toList();
}