Commit d842912 1 parent 8844d48 commit d842912 Copy full SHA for d842912
File tree 4 files changed +15
-1
lines changed
4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ class EnsembleForm extends StatefulWidget
68
68
_controller.labelStyle = Utils .getTextStyle (value),
69
69
'enabled' : (value) => _controller.enabled = Utils .optionalBool (value),
70
70
'readOnly' : (value) => _controller.readOnly = Utils .optionalBool (value),
71
+ 'dismissKeyboardOnSubmit' : (value) => _controller.dismissKeyboardOnSubmit = Utils .getBool (value, fallback: true ),
71
72
'width' : (value) => _controller.width = Utils .optionalInt (value),
72
73
'height' : (value) => _controller.height = Utils .optionalInt (value),
73
74
'gap' : (value) => _controller.gap =
@@ -110,6 +111,7 @@ class FormController extends WidgetController {
110
111
String ? labelOverflow;
111
112
bool ? enabled;
112
113
bool ? readOnly;
114
+ bool dismissKeyboardOnSubmit = true ;
113
115
114
116
// labelMaxWidth applicable only to labelPosition=start
115
117
int ? labelMaxWidth;
Original file line number Diff line number Diff line change @@ -280,7 +280,9 @@ class ButtonState extends EWidgetState<Button> {
280
280
// if focus in on a formfield (e.g. TextField), clicking on button will
281
281
// not remove focus, so its value is never updated. Unfocus here before
282
282
// executing button click ensure we get all the latest value of the form fields
283
- FocusManager .instance.primaryFocus? .unfocus ();
283
+ if (widget._controller.submitForm == false ) {
284
+ FocusManager .instance.primaryFocus? .unfocus ();
285
+ }
284
286
285
287
// submit the form if specified
286
288
if (widget._controller.submitForm == true ) {
Original file line number Diff line number Diff line change @@ -118,6 +118,10 @@ class FormHelper {
118
118
event: EnsembleEvent (formState.widget));
119
119
}
120
120
}
121
+ // only dismiss keyboard if dismissKeyboardOnSubmit is true (By default it is true)
122
+ if (formState? .widget.controller.dismissKeyboardOnSubmit == true ) {
123
+ FocusManager .instance.primaryFocus? .unfocus ();
124
+ }
121
125
}
122
126
}
123
127
Original file line number Diff line number Diff line change @@ -145,6 +145,8 @@ abstract class BaseTextInput extends StatefulWidget
145
145
'validator' : (value) => _controller.validator = Utils .getValidator (value),
146
146
'enableClearText' : (value) =>
147
147
_controller.enableClearText = Utils .optionalBool (value),
148
+ 'dismissibleKeyboard' : (value) =>
149
+ _controller.dismissibleKeyboard = Utils .getBool (value, fallback: true ),
148
150
'obscureToggle' : (value) =>
149
151
_controller.obscureToggle = Utils .optionalBool (value),
150
152
'obscured' : (widget) => _controller.obscureText == true ,
@@ -224,6 +226,7 @@ class TextInputController extends FormFieldController with HasTextPlaceholder {
224
226
EnsembleAction ? onFocusReceived;
225
227
EnsembleAction ? onFocusLost;
226
228
bool ? enableClearText;
229
+ bool dismissibleKeyboard = true ;
227
230
228
231
// applicable only for TextInput
229
232
bool ? obscureText;
@@ -305,7 +308,10 @@ class TextInputState extends FormFieldWidgetState<BaseTextInput>
305
308
overlayEntry! .remove ();
306
309
overlayEntry = null ;
307
310
}
311
+ // only dismiss if dismissibleKeyboard is true (By Default dismissibleKeyboard is true)
312
+ if (widget._controller.dismissibleKeyboard == true ){
308
313
FocusManager .instance.primaryFocus? .unfocus ();
314
+ }
309
315
}
310
316
311
317
@override
You can’t perform that action at this time.
0 commit comments