listFontMetadata function
Returns a list of FontMetadatas.
Implementation
Future<List<FontMetadata>> listFontMetadata(
{String? id,
String? family,
List<String>? subsets,
List<int>? weights,
List<String>? styles,
String? defSubset,
bool? variable,
String? lastModified,
String? category,
String? version,
String? type}) async {
final query = {
'id': id,
'family': family,
'subsets': subsets,
'weights': weights?.map((weight) => weight.toString()),
'styles': styles,
'defSubset': defSubset,
'variable': variable,
'lastModified': lastModified,
'category': category,
'version': version,
'type': type,
};
query.removeWhere((_, value) => value == null);
final response = await http
.get(Uri.parse('$apiUrl/v1/fonts?${Uri(queryParameters: query).query}'));
List<dynamic> fonts = jsonDecode(response.body);
return fonts.map((font) => FontMetadata.fromMap(font)).toList();
}