Skip to content

Commit 23e0c16

Browse files
feat: add missing text field properties
1 parent 9367d73 commit 23e0c16

File tree

1 file changed

+133
-71
lines changed

1 file changed

+133
-71
lines changed

lib/src/presentation/language_tool_text_field.dart

Lines changed: 133 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,104 @@
1+
import 'dart:ui' as ui;
2+
3+
import 'package:flutter/gestures.dart';
14
import 'package:flutter/material.dart';
25
import 'package:languagetool_textfield/src/core/controllers/language_tool_controller.dart';
36
import 'package:languagetool_textfield/src/utils/mistake_popup.dart';
47
import 'package:languagetool_textfield/src/utils/popup_overlay_renderer.dart';
58

69
/// A TextField widget that checks the grammar using the given
710
/// [LanguageToolController]
8-
class LanguageToolTextField extends StatefulWidget {
9-
/// A style to use for the text being edited.
10-
final TextStyle? style;
11-
12-
/// A decoration of this [TextField].
13-
final InputDecoration decoration;
14-
15-
/// Color scheme to highlight mistakes
16-
final LanguageToolController controller;
11+
class LanguageToolTextField extends TextField {
12+
/// LanguageToolController to highlight mistakes
13+
@override
14+
LanguageToolController get controller =>
15+
super.controller as LanguageToolController? ?? LanguageToolController();
1716

1817
/// Mistake popup window
1918
final MistakePopup? mistakePopup;
2019

21-
/// The maximum number of lines to show at one time, wrapping if necessary.
22-
final int? maxLines;
23-
24-
/// The minimum number of lines to occupy when the content spans fewer lines.
25-
final int? minLines;
26-
27-
/// Whether this widget's height will be sized to fill its parent.
28-
final bool expands;
29-
3020
/// A language code like en-US, de-DE, fr, or auto to guess
3121
/// the language automatically.
3222
/// ```language``` = 'auto' by default.
3323
final String language;
3424

35-
/// Determine text alignment
36-
/// textAlign = [TextAlign.start] by default.
37-
final TextAlign textAlign;
38-
39-
/// Determine text Direction
40-
final TextDirection? textDirection;
41-
25+
/// {@macro flutter.widgets.editableText.onChanged}
4226
final ValueChanged<String>? onTextChange;
27+
28+
/// {@macro flutter.widgets.editableText.onSubmitted}
4329
final ValueChanged<String>? onTextSubmitted;
44-
final VoidCallback? onTap;
45-
final TapRegionCallback? onTapOutside;
46-
final TextInputAction? textInputAction;
47-
final TextInputType? keyboardType;
48-
final Color? cursorColor;
49-
final bool autoFocus;
50-
final FocusNode? focusNode;
51-
final Brightness? keyboardAppearance;
52-
final bool autocorrect;
53-
final bool readOnly;
54-
final MouseCursor? mouseCursor;
30+
31+
/// Whether to center align the text field widget.
5532
final bool alignCenter;
5633

5734
/// Creates a widget that checks grammar errors.
5835
const LanguageToolTextField({
59-
required this.controller,
60-
this.style,
61-
this.decoration = const InputDecoration(),
62-
this.language = 'auto',
36+
required LanguageToolController super.controller,
6337
this.mistakePopup,
64-
this.maxLines = 1,
65-
this.minLines,
66-
this.expands = false,
67-
this.textAlign = TextAlign.start,
68-
this.textDirection,
69-
this.cursorColor,
70-
this.autocorrect = true,
71-
this.autoFocus = false,
72-
this.readOnly = false,
73-
this.textInputAction,
74-
this.keyboardType,
75-
this.focusNode,
76-
this.keyboardAppearance,
77-
this.mouseCursor,
78-
this.onTap,
79-
this.onTapOutside,
38+
this.language = 'auto',
8039
this.onTextChange,
8140
this.onTextSubmitted,
8241
this.alignCenter = true,
42+
super.focusNode,
43+
super.undoController,
44+
super.decoration = const InputDecoration(),
45+
super.keyboardType,
46+
super.textInputAction,
47+
super.textCapitalization = TextCapitalization.none,
48+
super.style,
49+
super.strutStyle,
50+
super.textAlign = TextAlign.start,
51+
super.textAlignVertical,
52+
super.textDirection,
53+
super.readOnly = false,
54+
super.showCursor,
55+
super.autofocus = false,
56+
super.statesController,
57+
super.obscuringCharacter = '•',
58+
super.obscureText = false,
59+
super.autocorrect = true,
60+
super.smartDashesType,
61+
super.smartQuotesType,
62+
super.enableSuggestions = true,
63+
super.maxLines = 1,
64+
super.minLines,
65+
super.expands = false,
66+
super.maxLength,
67+
super.maxLengthEnforcement,
68+
super.inputFormatters,
69+
super.enabled,
70+
super.ignorePointers,
71+
super.cursorWidth = 2.0,
72+
super.cursorHeight,
73+
super.cursorRadius,
74+
super.cursorOpacityAnimates,
75+
super.cursorColor,
76+
super.cursorErrorColor,
77+
super.selectionHeightStyle = ui.BoxHeightStyle.tight,
78+
super.selectionWidthStyle = ui.BoxWidthStyle.tight,
79+
super.keyboardAppearance,
80+
super.scrollPadding = const EdgeInsets.all(20.0),
81+
super.dragStartBehavior = DragStartBehavior.start,
82+
super.enableInteractiveSelection,
83+
super.selectionControls,
84+
super.onTap,
85+
super.onTapAlwaysCalled = false,
86+
super.onTapOutside,
87+
super.onTapUpOutside,
88+
super.mouseCursor,
89+
super.buildCounter,
90+
super.scrollController,
91+
super.scrollPhysics,
92+
super.autofillHints,
93+
super.contentInsertionConfiguration,
94+
super.clipBehavior = Clip.hardEdge,
95+
super.restorationId,
96+
super.stylusHandwritingEnabled = true,
97+
super.enableIMEPersonalizedLearning = true,
98+
super.contextMenuBuilder,
99+
super.canRequestFocus = true,
100+
super.spellCheckConfiguration,
101+
super.magnifierConfiguration,
83102
super.key,
84103
});
85104

@@ -121,33 +140,76 @@ class _LanguageToolTextFieldState extends State<LanguageToolTextField> {
121140
),
122141
);
123142

124-
final inputDecoration = widget.decoration.copyWith(
143+
final inputDecoration = widget.decoration?.copyWith(
125144
suffix: fetchError != null ? httpErrorText : null,
126145
);
127146

128147
Widget childWidget = TextField(
129-
textAlign: widget.textAlign,
130-
textDirection: widget.textDirection,
131-
focusNode: _focusNode,
132148
controller: widget.controller,
149+
focusNode: _focusNode,
133150
scrollController: _scrollController,
134151
decoration: inputDecoration,
135-
minLines: widget.minLines,
136-
maxLines: widget.maxLines,
137-
expands: widget.expands,
138-
style: widget.style,
139-
cursorColor: widget.cursorColor,
140-
autocorrect: widget.autocorrect,
141-
textInputAction: widget.textInputAction,
142-
keyboardAppearance: widget.keyboardAppearance,
143152
keyboardType: widget.keyboardType,
144-
autofocus: widget.autoFocus,
153+
textInputAction: widget.textInputAction,
154+
textCapitalization: widget.textCapitalization,
155+
style: widget.style,
156+
strutStyle: widget.strutStyle,
157+
textAlign: widget.textAlign,
158+
textAlignVertical: widget.textAlignVertical,
159+
textDirection: widget.textDirection,
160+
autofocus: widget.autofocus,
161+
statesController: widget.statesController,
145162
readOnly: widget.readOnly,
146-
mouseCursor: widget.mouseCursor,
163+
showCursor: widget.showCursor,
164+
obscuringCharacter: widget.obscuringCharacter,
165+
obscureText: widget.obscureText,
166+
autocorrect: widget.autocorrect,
167+
smartDashesType: widget.smartDashesType,
168+
smartQuotesType: widget.smartQuotesType,
169+
enableSuggestions: widget.enableSuggestions,
170+
maxLengthEnforcement: widget.maxLengthEnforcement,
171+
maxLines: widget.maxLines,
172+
minLines: widget.minLines,
173+
expands: widget.expands,
174+
maxLength: widget.maxLength,
147175
onChanged: widget.onTextChange,
148-
onSubmitted: widget.onTextSubmitted,
149176
onTap: widget.onTap,
177+
onTapAlwaysCalled: widget.onTapAlwaysCalled,
150178
onTapOutside: widget.onTapOutside,
179+
onTapUpOutside: widget.onTapUpOutside,
180+
onEditingComplete: widget.onEditingComplete,
181+
onSubmitted: widget.onTextSubmitted,
182+
inputFormatters: widget.inputFormatters,
183+
enabled: widget.enabled,
184+
ignorePointers: widget.ignorePointers,
185+
cursorWidth: widget.cursorWidth,
186+
cursorHeight: widget.cursorHeight,
187+
cursorRadius: widget.cursorRadius,
188+
cursorColor: widget.cursorColor,
189+
cursorErrorColor: widget.cursorErrorColor,
190+
scrollPadding: widget.scrollPadding,
191+
scrollPhysics: widget.scrollPhysics,
192+
keyboardAppearance: widget.keyboardAppearance,
193+
enableInteractiveSelection: widget.enableInteractiveSelection,
194+
selectionControls: widget.selectionControls,
195+
buildCounter: widget.buildCounter,
196+
autofillHints: widget.autofillHints,
197+
mouseCursor: widget.mouseCursor,
198+
contextMenuBuilder: widget.contextMenuBuilder,
199+
spellCheckConfiguration: widget.spellCheckConfiguration,
200+
magnifierConfiguration: widget.magnifierConfiguration,
201+
undoController: widget.undoController,
202+
onAppPrivateCommand: widget.onAppPrivateCommand,
203+
cursorOpacityAnimates: widget.cursorOpacityAnimates,
204+
selectionHeightStyle: widget.selectionHeightStyle,
205+
selectionWidthStyle: widget.selectionWidthStyle,
206+
dragStartBehavior: widget.dragStartBehavior,
207+
contentInsertionConfiguration: widget.contentInsertionConfiguration,
208+
clipBehavior: widget.clipBehavior,
209+
stylusHandwritingEnabled: widget.stylusHandwritingEnabled,
210+
canRequestFocus: widget.canRequestFocus,
211+
enableIMEPersonalizedLearning: widget.enableIMEPersonalizedLearning,
212+
restorationId: widget.restorationId,
151213
);
152214

153215
if (widget.alignCenter) {

0 commit comments

Comments
 (0)