queryFromFolder method

  1. @override
Future<List<SongModel>> queryFromFolder(
  1. String path, {
  2. SongSortType? sortType,
  3. OrderType? orderType,
  4. UriType? uriType,
})
override

Used to return Songs Info from a specific Folder based in SongModel.

Parameters:

  • path is used to define where the plugin will search for audio.
  • orderType is used to define if order will be Ascending or Descending.
  • sortType is used to define list sort.
  • uriType is used to define if songs will be catch in EXTERNAL or INTERNAL storage.

Important:

  • 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 Android >= Q/10 artwork will return null, in this case, it's necessary use queryArtwork.

Platforms:

Android IOS Web
✔️

See more about platforms support

Implementation

@override
Future<List<SongModel>> queryFromFolder(
  String path, {
  SongSortType? sortType,
  OrderType? orderType,
  UriType? uriType,
}) async {
  final List<dynamic> resultFromFolder = await _channel.invokeMethod(
    "queryFromFolder",
    {
      "sortType":
          sortType != null ? sortType.index : SongSortType.TITLE.index,
      "orderType": orderType != null
          ? orderType.index
          : OrderType.ASC_OR_SMALLER.index,
      "uri": uriType != null ? uriType.index : UriType.EXTERNAL.index,
      "path": path
    },
  );
  return resultFromFolder.map((songInfo) => SongModel(songInfo)).toList();
}