Skip to content

Commit 5215630

Browse files
feat: add missing properties to text field
1 parent bbd447c commit 5215630

File tree

1 file changed

+144
-96
lines changed

1 file changed

+144
-96
lines changed

lib/src/fields/form_builder_cupertino_text_field.dart

Lines changed: 144 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ class FormBuilderCupertinoTextField extends FormBuilderField<String> {
284284
/// {@macro flutter.widgets.editableText.scribbleEnabled}
285285
final bool scribbleEnabled;
286286

287+
/// {@macro flutter.widgets.editableText.stylusHandwritingEnabled}
288+
final bool stylusHandwritingEnabled;
289+
287290
/// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning}
288291
final bool enableIMEPersonalizedLearning;
289292

@@ -300,6 +303,29 @@ class FormBuilderCupertinoTextField extends FormBuilderField<String> {
300303
/// {@macro flutter.widgets.editableText.contentInsertionConfiguration}
301304
final ContentInsertionConfiguration? contentInsertionConfiguration;
302305

306+
/// {@macro flutter.widgets.undoHistory.controller}
307+
final UndoHistoryController? undoController;
308+
309+
/// {@macro flutter.widgets.editableText.selectionControls}
310+
final TextSelectionControls? selectionControls;
311+
312+
/// {@macro flutter.widgets.editableText.groupId}
313+
final Object groupId;
314+
315+
/// {@macro flutter.widgets.EditableText.spellCheckConfiguration}
316+
///
317+
/// If [SpellCheckConfiguration.misspelledTextStyle] is not specified in this
318+
/// configuration, then [cupertinoMisspelledTextStyle] is used by default.
319+
final SpellCheckConfiguration? spellCheckConfiguration;
320+
321+
/// {@macro flutter.material.Material.clipBehavior}
322+
///
323+
/// Defaults to [Clip.hardEdge].
324+
final Clip clipBehavior;
325+
326+
/// {@macro flutter.widgets.editableText.cursorOpacityAnimates}
327+
final bool cursorOpacityAnimates;
328+
303329
FormBuilderCupertinoTextField({
304330
super.key,
305331
required super.name,
@@ -363,107 +389,129 @@ class FormBuilderCupertinoTextField extends FormBuilderField<String> {
363389
this.contentPadding,
364390
this.prefix,
365391
this.enableIMEPersonalizedLearning = true,
392+
this.undoController,
393+
this.selectionControls,
394+
this.groupId = EditableText,
395+
this.spellCheckConfiguration,
396+
this.clipBehavior = Clip.hardEdge,
397+
this.cursorOpacityAnimates = true,
398+
@Deprecated(
399+
'Use `stylusHandwritingEnabled` instead. '
400+
'This feature was deprecated after v3.27.0-0.2.pre.',
401+
)
366402
this.scribbleEnabled = true,
403+
this.stylusHandwritingEnabled =
404+
EditableText.defaultStylusHandwritingEnabled,
367405
this.clearButtonMode = OverlayVisibilityMode.never,
368406
this.contentInsertionConfiguration,
369407
this.placeholder,
370408
this.placeholderStyle,
371-
}) : assert(maxLines == null || maxLines > 0),
372-
assert(minLines == null || minLines > 0),
373-
assert(
374-
(maxLines == null) || (minLines == null) || (maxLines >= minLines),
375-
"minLines can't be greater than maxLines",
376-
),
377-
assert(
378-
!expands || (maxLines == null && minLines == null),
379-
'minLines and maxLines must be null when expands is true.',
380-
),
381-
assert(!obscureText || maxLines == 1,
382-
'Obscured fields cannot be multiline.'),
383-
assert(maxLength == null || maxLength > 0),
384-
// Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
385-
assert(
386-
!identical(textInputAction, TextInputAction.newline) ||
387-
maxLines == 1 ||
388-
!identical(keyboardType, TextInputType.text),
389-
'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.',
390-
),
391-
super(
392-
initialValue: controller != null ? controller.text : initialValue,
393-
builder: (FormFieldState<String?> field) {
394-
final state = field as _FormBuilderCupertinoTextFieldState;
395-
396-
final fieldWidget = CupertinoTextField(
397-
restorationId: restorationId,
398-
controller: state._effectiveController,
399-
focusNode: state.effectiveFocusNode,
400-
decoration: decoration,
401-
keyboardType: keyboardType,
402-
textInputAction: textInputAction,
403-
style: style,
404-
strutStyle: strutStyle,
405-
textAlign: textAlign,
406-
textAlignVertical: textAlignVertical,
407-
textDirection: textDirection,
408-
textCapitalization: textCapitalization,
409-
autofocus: autofocus,
410-
readOnly: readOnly,
411-
showCursor: showCursor,
412-
obscureText: obscureText,
413-
autocorrect: autocorrect,
414-
enableSuggestions: enableSuggestions,
415-
placeholder: placeholder,
416-
placeholderStyle: placeholderStyle,
417-
maxLengthEnforcement: maxLengthEnforcement,
418-
maxLines: maxLines,
419-
minLines: minLines,
420-
expands: expands,
421-
maxLength: maxLength,
422-
onTap: onTap,
423-
onTapOutside: onTapOutside,
424-
onEditingComplete: onEditingComplete,
425-
onSubmitted: onSubmitted,
426-
inputFormatters: inputFormatters,
427-
enabled: state.enabled,
428-
cursorWidth: cursorWidth,
429-
cursorHeight: cursorHeight,
430-
cursorRadius: cursorRadius,
431-
cursorColor: cursorColor,
432-
scrollPadding: scrollPadding,
433-
keyboardAppearance: keyboardAppearance,
434-
enableInteractiveSelection: enableInteractiveSelection,
435-
dragStartBehavior: dragStartBehavior,
436-
scrollController: scrollController,
437-
scrollPhysics: scrollPhysics,
438-
selectionHeightStyle: selectionHeightStyle,
439-
selectionWidthStyle: selectionWidthStyle,
440-
smartDashesType: smartDashesType,
441-
smartQuotesType: smartQuotesType,
442-
contextMenuBuilder: contextMenuBuilder,
443-
obscuringCharacter: obscuringCharacter,
444-
autofillHints: autofillHints,
445-
magnifierConfiguration: magnifierConfiguration,
446-
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
447-
scribbleEnabled: scribbleEnabled,
448-
clearButtonMode: clearButtonMode,
449-
contentInsertionConfiguration: contentInsertionConfiguration,
450-
);
451-
452-
return CupertinoFormRow(
453-
error: state.hasError
454-
? errorBuilder != null
455-
? errorBuilder(state.errorText ?? '')
456-
: Text(state.errorText ?? '')
457-
: null,
458-
helper: helper,
459-
padding: contentPadding,
460-
prefix: prefix,
461-
child: shouldExpandedField
462-
? SizedBox(width: double.infinity, child: fieldWidget)
463-
: fieldWidget,
464-
);
465-
},
466-
);
409+
}) : assert(maxLines == null || maxLines > 0),
410+
assert(minLines == null || minLines > 0),
411+
assert(
412+
(maxLines == null) || (minLines == null) || (maxLines >= minLines),
413+
"minLines can't be greater than maxLines",
414+
),
415+
assert(
416+
!expands || (maxLines == null && minLines == null),
417+
'minLines and maxLines must be null when expands is true.',
418+
),
419+
assert(
420+
!obscureText || maxLines == 1,
421+
'Obscured fields cannot be multiline.',
422+
),
423+
assert(maxLength == null || maxLength > 0),
424+
// Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
425+
assert(
426+
!identical(textInputAction, TextInputAction.newline) ||
427+
maxLines == 1 ||
428+
!identical(keyboardType, TextInputType.text),
429+
'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.',
430+
),
431+
super(
432+
initialValue: controller != null ? controller.text : initialValue,
433+
builder: (FormFieldState<String?> field) {
434+
final state = field as _FormBuilderCupertinoTextFieldState;
435+
436+
final fieldWidget = CupertinoTextField(
437+
restorationId: restorationId,
438+
controller: state._effectiveController,
439+
focusNode: state.effectiveFocusNode,
440+
decoration: decoration,
441+
keyboardType: keyboardType,
442+
textInputAction: textInputAction,
443+
style: style,
444+
strutStyle: strutStyle,
445+
textAlign: textAlign,
446+
textAlignVertical: textAlignVertical,
447+
textDirection: textDirection,
448+
textCapitalization: textCapitalization,
449+
autofocus: autofocus,
450+
readOnly: readOnly,
451+
showCursor: showCursor,
452+
obscureText: obscureText,
453+
autocorrect: autocorrect,
454+
enableSuggestions: enableSuggestions,
455+
placeholder: placeholder,
456+
placeholderStyle: placeholderStyle,
457+
maxLengthEnforcement: maxLengthEnforcement,
458+
maxLines: maxLines,
459+
minLines: minLines,
460+
expands: expands,
461+
maxLength: maxLength,
462+
onTap: onTap,
463+
onTapOutside: onTapOutside,
464+
onEditingComplete: onEditingComplete,
465+
onSubmitted: onSubmitted,
466+
inputFormatters: inputFormatters,
467+
enabled: state.enabled,
468+
cursorWidth: cursorWidth,
469+
cursorHeight: cursorHeight,
470+
cursorRadius: cursorRadius,
471+
cursorColor: cursorColor,
472+
scrollPadding: scrollPadding,
473+
keyboardAppearance: keyboardAppearance,
474+
enableInteractiveSelection: enableInteractiveSelection,
475+
dragStartBehavior: dragStartBehavior,
476+
scrollController: scrollController,
477+
scrollPhysics: scrollPhysics,
478+
selectionHeightStyle: selectionHeightStyle,
479+
selectionWidthStyle: selectionWidthStyle,
480+
smartDashesType: smartDashesType,
481+
smartQuotesType: smartQuotesType,
482+
contextMenuBuilder: contextMenuBuilder,
483+
obscuringCharacter: obscuringCharacter,
484+
autofillHints: autofillHints,
485+
magnifierConfiguration: magnifierConfiguration,
486+
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
487+
stylusHandwritingEnabled: stylusHandwritingEnabled,
488+
undoController: undoController,
489+
selectionControls: selectionControls,
490+
groupId: groupId,
491+
spellCheckConfiguration: spellCheckConfiguration,
492+
clipBehavior: clipBehavior,
493+
cursorOpacityAnimates: cursorOpacityAnimates,
494+
clearButtonMode: clearButtonMode,
495+
contentInsertionConfiguration: contentInsertionConfiguration,
496+
);
497+
498+
return CupertinoFormRow(
499+
error:
500+
state.hasError
501+
? errorBuilder != null
502+
? errorBuilder(state.errorText ?? '')
503+
: Text(state.errorText ?? '')
504+
: null,
505+
helper: helper,
506+
padding: contentPadding,
507+
prefix: prefix,
508+
child:
509+
shouldExpandedField
510+
? SizedBox(width: double.infinity, child: fieldWidget)
511+
: fieldWidget,
512+
);
513+
},
514+
);
467515

468516
static Widget _defaultContextMenuBuilder(
469517
BuildContext context,

0 commit comments

Comments
 (0)