check method

Future<List<WritingMistake>> check(
  1. String text
)

Check a text with LanguageTool for possible style and grammar issues.

If no mistake were found, this returns an empty list

Implementation

Future<List<WritingMistake>> check(String text) async {
  final languageToolUri = Uri.https(_url, 'v2/check');
  final res = await http.post(
    languageToolUri,
    headers: _headers,
    body: _formatDataArgument(text),
  );

  if (res.statusCode != 200) {
    throw Exception('http.post error: ${res.statusCode} ${res.reasonPhrase}');
  }

  final languageToolAnswer = LanguageToolAnswerRaw.fromJson(
    json.decode(utf8.decode(res.bodyBytes)) as Map<String, dynamic>,
  );

  return parseWritings(languageToolAnswer);
}