isFavoritedBatch static method

Future<Map<String, bool>> isFavoritedBatch(
  1. List<String> ids,
  2. String category
)

Implementation

static Future<Map<String, bool>> isFavoritedBatch(
    List<String> ids, String category) async {
  String baseUrl = Preferences.prefs?.getString("BaseUrl") ?? "";
  String apiUrl = "$baseUrl/api/favorite/batch";

  var headers = await BaseApi.getRefreshedHeaders();

  Uri uri = Uri.parse(apiUrl).replace(
    queryParameters: {
      "ids": ids,
      "category": category,
    },
  );

  var response = await http.get(uri, headers: headers);

  if (response.statusCode == 200) {
    Map<String, dynamic> jsonResponse = json.decode(response.body);
    return jsonResponse.map((key, value) => MapEntry(key, value as bool));
  } else {
    throw Exception('Failed to fetch favorites: ${response.body}');
  }
}