@@ -466,7 +466,7 @@ class TextInputConfiguration {
466466 this .inputAction = TextInputAction .done,
467467 this .keyboardAppearance = Brightness .light,
468468 this .textCapitalization = TextCapitalization .none,
469- this .autofillConfiguration,
469+ this .autofillConfiguration = AutofillConfiguration .disabled ,
470470 this .enableIMEPersonalizedLearning = true ,
471471 }) : assert (inputType != null ),
472472 assert (obscureText != null ),
@@ -503,7 +503,7 @@ class TextInputConfiguration {
503503 /// to the platform. This will prevent the corresponding input field from
504504 /// participating in autofills triggered by other fields. Additionally, on
505505 /// Android and web, setting [autofillConfiguration] to null disables autofill.
506- final AutofillConfiguration ? autofillConfiguration;
506+ final AutofillConfiguration autofillConfiguration;
507507
508508 /// {@template flutter.services.TextInputConfiguration.smartDashesType}
509509 /// Whether to allow the platform to automatically format dashes.
@@ -607,8 +607,41 @@ class TextInputConfiguration {
607607 /// {@endtemplate}
608608 final bool enableIMEPersonalizedLearning;
609609
610+ /// Creates a copy of this [TextInputConfiguration] with the given fields
611+ /// replaced with new values.
612+ TextInputConfiguration copyWith ({
613+ TextInputType ? inputType,
614+ bool ? readOnly,
615+ bool ? obscureText,
616+ bool ? autocorrect,
617+ SmartDashesType ? smartDashesType,
618+ SmartQuotesType ? smartQuotesType,
619+ bool ? enableSuggestions,
620+ String ? actionLabel,
621+ TextInputAction ? inputAction,
622+ Brightness ? keyboardAppearance,
623+ TextCapitalization ? textCapitalization,
624+ bool ? enableIMEPersonalizedLearning,
625+ AutofillConfiguration ? autofillConfiguration,
626+ }) {
627+ return TextInputConfiguration (
628+ inputType: inputType ?? this .inputType,
629+ readOnly: readOnly ?? this .readOnly,
630+ obscureText: obscureText ?? this .obscureText,
631+ autocorrect: autocorrect ?? this .autocorrect,
632+ smartDashesType: smartDashesType ?? this .smartDashesType,
633+ smartQuotesType: smartQuotesType ?? this .smartQuotesType,
634+ enableSuggestions: enableSuggestions ?? this .enableSuggestions,
635+ inputAction: inputAction ?? this .inputAction,
636+ textCapitalization: textCapitalization ?? this .textCapitalization,
637+ keyboardAppearance: keyboardAppearance ?? this .keyboardAppearance,
638+ enableIMEPersonalizedLearning: enableIMEPersonalizedLearning?? this .enableIMEPersonalizedLearning,
639+ autofillConfiguration: autofillConfiguration ?? this .autofillConfiguration,
640+ );
641+ }
610642 /// Returns a representation of this object as a JSON object.
611643 Map <String , dynamic > toJson () {
644+ final Map <String , dynamic >? autofill = autofillConfiguration.toJson ();
612645 return < String , dynamic > {
613646 'inputType' : inputType.toJson (),
614647 'readOnly' : readOnly,
@@ -622,7 +655,7 @@ class TextInputConfiguration {
622655 'textCapitalization' : textCapitalization.toString (),
623656 'keyboardAppearance' : keyboardAppearance.toString (),
624657 'enableIMEPersonalizedLearning' : enableIMEPersonalizedLearning,
625- if (autofillConfiguration != null ) 'autofill' : autofillConfiguration ! . toJson () ,
658+ if (autofill != null ) 'autofill' : autofill ,
626659 };
627660 }
628661}
@@ -1470,7 +1503,10 @@ class TextInput {
14701503 final TextEditingValue textEditingValue = TextEditingValue .fromJSON (
14711504 editingValue[tag] as Map <String , dynamic >,
14721505 );
1473- scope? .getAutofillClient (tag)? .updateEditingValue (textEditingValue);
1506+ final AutofillClient ? client = scope? .getAutofillClient (tag);
1507+ if (client != null && client.textInputConfiguration.autofillConfiguration.enabled) {
1508+ client.autofill (textEditingValue);
1509+ }
14741510 }
14751511
14761512 return ;
0 commit comments