followedByUsers method

Future<Map<String, bool>> followedByUsers(
  1. String playlistId,
  2. List<String> userIds
)

check if a playlist is followed by provided users playlistId - the playlist ID userIds - the ids of the users

Returns the list of userIds mapped with whether they are following or not

Implementation

Future<Map<String, bool>> followedByUsers(
    String playlistId, List<String> userIds) async {
  assert(userIds.isNotEmpty, 'No user id was provided for checking');
  final jsonString = await _api._get(
    'v1/playlists/$playlistId/followers/contains?ids=${userIds.join(",")}',
  );
  final list = List.castFrom<dynamic, bool>(json.decode(jsonString));
  return Map.fromIterables(userIds, list);
}