fetchFigmaFile method
Fetches a figma file or specific nodes if nodeId is provided
Implementation
Future<Map<String, dynamic>?> fetchFigmaFile(String fileKey, {String? nodeId}) async {
final endpoint = nodeId != null
? 'https://api.figma.com/v1/files/$fileKey/nodes?ids=$nodeId'
: 'https://api.figma.com/v1/files/$fileKey';
try {
final response = await http.get(
Uri.parse(endpoint),
headers: {
'X-Figma-Token': token,
},
);
if (response.statusCode == 200) {
return json.decode(response.body);
} else {
print('❌ Figma API Error: ${response.statusCode} - ${response.body}');
return null;
}
} catch (e) {
print('❌ Error fetching Figma file: $e');
return null;
}
}