getImageUrls method

Future<Map<String, dynamic>> getImageUrls(
  1. List<String> ids, {
  2. String format = 'pdf',
  3. int scale = 1,
})

Fetches image URLs for specified node IDs.

Parameters:

  • ids: List of node IDs to fetch images for
  • format: Image format (e.g., 'svg', 'pdf')
  • scale: Image scale factor

Returns a map of node IDs to their corresponding image URLs.

Implementation

Future<Map<String, dynamic>> getImageUrls(
  List<String> ids, {
  String format = 'pdf',
  int scale = 1,
}) async {
  final queryParams = {
    'ids': ids.join(','),
    'format': format,
    'scale': scale.toString(),
  };

  final uri = Uri.parse('$_baseUrl/images/$_fileId')
      .replace(queryParameters: queryParams);

  final response = await http.get(
    uri,
    headers: {'X-FIGMA-TOKEN': _token},
  );

  if (response.statusCode == 200) {
    final data = json.decode(response.body);
    return data['images'];
  } else {
    throw Exception('Failed to fetch image URLs: ${response.statusCode}');
  }
}