Skip to content

Commit

Permalink
Merge pull request #75 from Semsem-programmer/main
Browse files Browse the repository at this point in the history
Add textAlign and textDirection arguments to LanguageToolTextField constructor, enforce utf-8 decoding format for LanguageTool API responses. Credits: @Semsem-programmer
  • Loading branch information
solid-yuriiprykhodko authored Jan 30, 2024
2 parents 77b5cdd + eaa77db commit 6d069be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/client/language_tool_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LanguageToolClient {
);

final languageToolAnswer = LanguageToolRaw.fromJson(
json.decode(result.body) as Map<String, dynamic>,
json.decode(utf8.decode(result.bodyBytes)) as Map<String, dynamic>,
);

return _parseRawAnswer(languageToolAnswer);
Expand Down
11 changes: 11 additions & 0 deletions lib/presentation/language_tool_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class LanguageToolTextField extends StatefulWidget {
/// ```language``` = 'auto' by default.
final String language;
/// Determine text alignment
/// textAlign = [TextAlign.start] by default.
final TextAlign textAlign;
/// Determine text Direction
final TextDirection? textDirection;
/// Creates a widget that checks grammar errors.
const LanguageToolTextField({
required this.controller,
Expand All @@ -42,6 +49,8 @@ class LanguageToolTextField extends StatefulWidget {
this.maxLines = 1,
this.minLines,
this.expands = false,
this.textAlign = TextAlign.start,
this.textDirection,
super.key,
});
Expand Down Expand Up @@ -92,6 +101,8 @@ class _LanguageToolTextFieldState extends State<LanguageToolTextField> {
padding: const EdgeInsets.all(_padding),
child: Center(
child: TextField(
textAlign: widget.textAlign,
textDirection: widget.textDirection,
focusNode: _focusNode,
controller: widget.controller,
scrollController: _scrollController,
Expand Down

0 comments on commit 6d069be

Please sign in to comment.