getVariants method

Future<List<Language>> getVariants({
  1. required String baseUrl,
  2. required String apiKey,
})

Fetches the variants enabled on Ditto

throws FailedFetchException if the request fails

Implementation

Future<List<Language>> getVariants({
  required String baseUrl,
  required String apiKey,
}) async {
  final response = await _provider.get(
    baseUrl: baseUrl,
    apiKey: apiKey,
    path: '/variants',
  );
  if (response.statusCode == 200) {
    return (jsonDecode(response.body) as List<dynamic>)
        .map((d) => Language.fromJson(d))
        .toList();
  }
  throw FailedFetchException(response.body);
}