getVariables method

Future<Map<String, dynamic>> getVariables()

Fetches all variables from the Figma file.

Returns a JSON object containing all variable collections and their variables.

Implementation

Future<Map<String, dynamic>> getVariables() async {
  final response = await http.get(
    Uri.parse('$_baseUrl/files/$_fileId/variables/local'),
    headers: {'X-FIGMA-TOKEN': _token},
  );

  if (response.statusCode == 200) {
    return json.decode(response.body);
  } else {
    throw Exception('Failed to fetch variables: ${response.statusCode}');
  }
}