queryAudiosOnly method Null safety

Future<List<SongModel>> queryAudiosOnly(
  1. AudiosOnlyType isOnly,
  2. [SongSortType? sortType,
  3. OrderType? orderType,
  4. bool? requestPermission]
)

Used to return Songs Info based in SongModel.

This method is similar to querySongs, but, will return only audio types specifics in AudiosOnlyType

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.
  • isOnly is used to define what audio type you want.

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.
  • Some types exclusively for Android >= Q/29, if you try call them in a Android below will return all types together.
  • If Android >= Q/10 artwork will return null, in this case, it's necessary use queryArtworks.

Implementation

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