Skip to content

Commit 6d069be

Browse files
Merge pull request #75 from Semsem-programmer/main
Add textAlign and textDirection arguments to LanguageToolTextField constructor, enforce utf-8 decoding format for LanguageTool API responses. Credits: @Semsem-programmer
2 parents 77b5cdd + eaa77db commit 6d069be

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/client/language_tool_client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LanguageToolClient {
3838
);
3939

4040
final languageToolAnswer = LanguageToolRaw.fromJson(
41-
json.decode(result.body) as Map<String, dynamic>,
41+
json.decode(utf8.decode(result.bodyBytes)) as Map<String, dynamic>,
4242
);
4343

4444
return _parseRawAnswer(languageToolAnswer);

lib/presentation/language_tool_text_field.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ class LanguageToolTextField extends StatefulWidget {
3232
/// ```language``` = 'auto' by default.
3333
final String language;
3434

35+
/// Determine text alignment
36+
/// textAlign = [TextAlign.start] by default.
37+
final TextAlign textAlign;
38+
39+
/// Determine text Direction
40+
final TextDirection? textDirection;
41+
3542
/// Creates a widget that checks grammar errors.
3643
const LanguageToolTextField({
3744
required this.controller,
@@ -42,6 +49,8 @@ class LanguageToolTextField extends StatefulWidget {
4249
this.maxLines = 1,
4350
this.minLines,
4451
this.expands = false,
52+
this.textAlign = TextAlign.start,
53+
this.textDirection,
4554
super.key,
4655
});
4756

@@ -92,6 +101,8 @@ class _LanguageToolTextFieldState extends State<LanguageToolTextField> {
92101
padding: const EdgeInsets.all(_padding),
93102
child: Center(
94103
child: TextField(
104+
textAlign: widget.textAlign,
105+
textDirection: widget.textDirection,
95106
focusNode: _focusNode,
96107
controller: widget.controller,
97108
scrollController: _scrollController,

0 commit comments

Comments
 (0)