fetchTranslations static method

Future<Map<String, dynamic>?> fetchTranslations()

Fetched the newest translation from the provided translationsPath returns Future<Map<String, dynamic>> Throws an WrongApiResponseException if there is response status was not 200

Implementation

static Future<Map<String, dynamic>?> fetchTranslations() async {
  try {
    final response = await http.get(
      Uri.parse(Translatron.getHostname + Translatron.getTranslationsPath),
      headers: Translatron.getApiHeaders,
    );

    if (response.statusCode == 200) {
      return json.decode(response.body);
    } else {
      throw WrongApiResponseException();
    }
  } catch (e) {
    // ExceptionHandler.returnException(e);
    return null;
  }
}