fetchFile function
Implementation
Future<FigmaFile?> fetchFile(String key, String token) async {
final headers = {'X-Figma-Token': token};
final dio = Dio();
final response = await dio.request<dynamic>(
'https://api.figma.com/v1/files/$key',
options: Options(
method: 'GET',
headers: headers,
),
);
if (response.statusCode == 200) {
return FigmaFile.fromJson(response.data);
} else {
stdout.writeln(response.statusMessage);
return null;
}
}