@@ -3,55 +3,156 @@ import 'package:flutter/material.dart';
3
3
import 'package:flutter/services.dart' ;
4
4
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart' ;
5
5
6
+ /// A custom form field widget that integrates with a form manager and offers various configurable input properties.
7
+ ///
8
+ /// The `FancyFormField` widget allows you to customize the behavior and appearance of a text input field,
9
+ /// including validation, input formatting, and styling.
6
10
class FancyFormField extends StatefulWidget {
11
+ /// Controls the validation and auto-validation mode for the field.
7
12
final AutovalidateMode ? autovalidateMode;
13
+
14
+ /// A unique key to identify this field in the form.
8
15
final FancyKey fancyKey;
16
+
17
+ /// The controller for the text input field.
9
18
final TextEditingController ? controller;
19
+
20
+ /// Whether the field is enabled or not.
10
21
final bool ? enabled;
22
+
23
+ /// A forced error message to display instead of the default error messages.
11
24
final String ? forceErrorText;
25
+
26
+ /// The initial value of the field.
12
27
final String ? initialValue;
28
+
29
+ /// A callback that is invoked when the field value changes.
13
30
final ValueChanged <String >? onChanged;
31
+
32
+ /// A callback that is invoked when the form is saved.
14
33
final FormFieldSetter <String >? onSaved;
34
+
35
+ /// The restoration ID used to restore the state of the field.
15
36
final String ? restorationId;
37
+
38
+ /// A validator function that validates the field input.
16
39
final FormFieldValidator <String >? validator;
40
+
41
+ /// A node that can be used to manage the focus state of the input field.
17
42
final FocusNode ? focusNode;
43
+
44
+ /// The decoration for the input field, such as label, hint, and icon.
18
45
final InputDecoration ? decoration;
46
+
47
+ /// The keyboard type (e.g., text, number, email).
19
48
final TextInputType ? keyboardType;
49
+
50
+ /// Controls text capitalization behavior for the field (e.g., none, sentences, words).
20
51
final TextCapitalization textCapitalization;
52
+
53
+ /// The action button on the keyboard (e.g., next, done).
21
54
final TextInputAction ? textInputAction;
55
+
56
+ /// The text style for the input field.
22
57
final TextStyle ? style;
58
+
59
+ /// The style for the text strut (line height).
23
60
final StrutStyle ? strutStyle;
61
+
62
+ /// The text direction for the input field (e.g., left-to-right, right-to-left).
24
63
final TextDirection ? textDirection;
64
+
65
+ /// The alignment of the text within the field (e.g., left, right, center).
25
66
final TextAlign textAlign;
67
+
68
+ /// The vertical alignment of the text within the field.
26
69
final TextAlignVertical ? textAlignVertical;
70
+
71
+ /// Whether the field should autofocus when the widget is built.
27
72
final bool autofocus;
73
+
74
+ /// Whether the field is read-only.
28
75
final bool readOnly;
76
+
77
+ /// Controls whether the cursor is visible in the field.
29
78
final bool ? showCursor;
79
+
80
+ /// The character to obscure the text when `obscureText` is enabled (e.g., `•` ).
30
81
final String obscuringCharacter;
82
+
83
+ /// Whether the field obscures the text (typically used for passwords).
31
84
final bool obscureText;
85
+
86
+ /// Whether autocorrection is enabled for the field.
32
87
final bool autocorrect;
88
+
89
+ /// A list of input formatters to apply to the input field.
33
90
final List <TextInputFormatter >? inputFormatters;
91
+
92
+ /// Whether suggestions (e.g., predictive text) are enabled.
34
93
final bool enableSuggestions;
94
+
95
+ /// The maximum number of lines that the input can occupy.
35
96
final int ? maxLines;
97
+
98
+ /// The minimum number of lines that the input can occupy.
36
99
final int ? minLines;
100
+
101
+ /// Whether the input should expand to fill the available space.
37
102
final bool expands;
103
+
104
+ /// The maximum length of the input.
38
105
final int ? maxLength;
106
+
107
+ /// A callback that is triggered when the input field is tapped.
39
108
final GestureTapCallback ? onTap;
109
+
110
+ /// Whether the `onTap` callback should always be called.
40
111
final bool onTapAlwaysCalled;
112
+
113
+ /// A callback that is triggered when tapping outside of the field.
41
114
final TapRegionCallback ? onTapOutside;
115
+
116
+ /// A callback that is triggered when editing is complete.
42
117
final VoidCallback ? onEditingComplete;
118
+
119
+ /// A callback that is triggered when the field value is submitted.
43
120
final ValueChanged <String >? onFieldSubmitted;
121
+
122
+ /// The scroll physics to apply to the field's scrollable area.
44
123
final ScrollPhysics ? scrollPhysics;
124
+
125
+ /// The controller for the scrollable area of the field.
45
126
final ScrollController ? scrollController;
127
+
128
+ /// The width of the cursor in the input field.
46
129
final double cursorWidth;
130
+
131
+ /// The height of the cursor in the input field.
47
132
final double ? cursorHeight;
133
+
134
+ /// The radius of the cursor.
48
135
final Radius ? cursorRadius;
136
+
137
+ /// The color of the cursor in the input field.
49
138
final Color ? cursorColor;
139
+
140
+ /// The color of the cursor when an error occurs.
50
141
final Color ? cursorErrorColor;
142
+
143
+ /// The appearance mode of the keyboard (e.g., light or dark).
51
144
final Brightness ? keyboardAppearance;
145
+
146
+ /// The padding for the scrollable area of the field.
52
147
final EdgeInsets scrollPadding;
148
+
149
+ /// Whether to enable personalized learning for the IME (Input Method Editor).
53
150
final bool enableIMEPersonalizedLearning;
151
+
152
+ /// Whether to allow interactive selection of the text in the input field.
54
153
final bool ? enableInteractiveSelection;
154
+
155
+ /// The clipping behavior for the input field.
55
156
final Clip clipBehavior;
56
157
57
158
const FancyFormField ({
@@ -111,6 +212,7 @@ class FancyFormField extends StatefulWidget {
111
212
State <FancyFormField > createState () => _FancyFormFieldState ();
112
213
}
113
214
215
+ /// The state of the `FancyFormField` widget, managing the text input controller and input formatters.
114
216
class _FancyFormFieldState extends State <FancyFormField > {
115
217
late final TextEditingController controller;
116
218
final List <TextInputFormatter > inputFormatters = [];
0 commit comments