fetchVariableCollections method

Future<Map<String, FigmaVariableCollection>> fetchVariableCollections()

Fetches and parses variable collections into strongly-typed objects.

Returns a map of collection IDs to FigmaVariableCollection objects. Throws an exception if the collections cannot be fetched or parsed.

Implementation

Future<Map<String, FigmaVariableCollection>>
    fetchVariableCollections() async {
  final response = await fetchVariables();
  final collections =
      response['meta']['variableCollections'] as Map<String, dynamic>;
  return collections.map((key, value) => MapEntry(
      key, FigmaVariableCollection.fromJson(value as Map<String, dynamic>)));
}