querySongs method

Future<List<SongModel>> querySongs([
  1. SongSortType? sortType,
  2. OrderType? orderType,
  3. UriType? uriType,
  4. bool? requestPermission,
  5. String? path,
])

Used to return Songs Info based in SongModel.

Parameters:

  • requestPermission is used for request or no Android STORAGE PERMISSION.
  • orderType is used to define if order will be Ascending or Descending.
  • sortType is used to define list sort.
  • path is used to define the local/path/folder where the songs will be queried.
  • uriType is used to define if songs will be catch in EXTERNAL or INTERNAL storage.

Important:

  • If requestPermission is null, will be set to false.
  • If orderType is null, will be set to ASC_OR_SMALLER.
  • If sortType is null, will be set to title.
  • If uriType is null, will be set to EXTERNAL.
  • If path is null, will be ignored.
  • If Android >= Q/10 artwork will return null, in this case, it's necessary use queryArtworks.

Implementation

Future<List<SongModel>> querySongs([
  SongSortType? sortType,
  OrderType? orderType,
  UriType? uriType,
  bool? requestPermission,
  String? path,
]) async {
  final List<dynamic> resultSongs =
      await _channel.invokeMethod("querySongs", {
    "requestPermission": _checkPermission(requestPermission),
    "sortType":
        sortType != null ? sortType.index : SongSortType.DEFAULT.index,
    "orderType": _checkOrder(orderType),
    "uri": uriType != null ? uriType.index : UriType.EXTERNAL.index,
    "path": path
  });
  return resultSongs.map((songInfo) => SongModel(songInfo)).toList();
}