Skip to content

Commit

Permalink
Merge pull request #54 from solid-software/bug/doesnt-find-mistake-ne…
Browse files Browse the repository at this point in the history
…xt-line

Bug/Can't find an error on the following line
  • Loading branch information
solid-danylokhvan authored Jul 6, 2023
2 parents 8e1ddc6 + f72e27a commit b49555b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/client/language_tool_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import 'package:languagetool_textfield/domain/writing_mistake.dart';
///
/// Read more @ https://languagetool.org/http-api/swagger-ui/#/
class LanguageToolClient {
/// A language code like en-US, de-DE, fr,
/// or auto to guess the language automatically
final String language;

/// Url of LanguageTool API.
static const _url = 'api.languagetoolplus.com';

Expand All @@ -18,24 +22,19 @@ class LanguageToolClient {
};

/// Constructor for [LanguageToolClient].
LanguageToolClient();
LanguageToolClient({this.language = 'auto'});

/// Checks the errors in text.
Future<List<WritingMistake>> check(
String text, {
String language = 'auto',
}) async {
final encodedText = Uri.encodeQueryComponent(text);
final encodedLanguage = Uri.encodeQueryComponent(language);

Future<List<WritingMistake>> check(String text) async {
final result = await http.post(
Uri.https(_url, 'v2/check', {
'text': encodedText,
'language': encodedLanguage,
Uri.https(_url, 'v2/check'),
headers: _headers,
body: {
'text': text,
'language': language,
'enabledOnly': 'false',
'level': 'default',
}),
headers: _headers,
},
);

final languageToolAnswer = LanguageToolRaw.fromJson(
Expand Down

0 comments on commit b49555b

Please sign in to comment.