@@ -114,8 +114,10 @@ class EngineAutofillForm {
114
114
if (fields != null ) {
115
115
for (Map <String , dynamic > field in fields.cast <Map <String , dynamic >>()) {
116
116
final Map <String , dynamic > autofillInfo = field['autofill' ];
117
- final AutofillInfo autofill =
118
- AutofillInfo .fromFrameworkMessage (autofillInfo);
117
+ final AutofillInfo autofill = AutofillInfo .fromFrameworkMessage (
118
+ autofillInfo,
119
+ textCapitalization: TextCapitalizationUtil .fromInputConfiguration (
120
+ field['textCapitalization' ]));
119
121
120
122
// The focused text editing element will not be created here.
121
123
final AutofillInfo focusedElement =
@@ -169,17 +171,24 @@ class EngineAutofillForm {
169
171
keys.forEach ((String key) {
170
172
final html.Element element = elements! [key]! ;
171
173
subscriptions.add (element.onInput.listen ((html.Event e) {
172
- _handleChange (element, key);
174
+ if (items! [key] == null ) {
175
+ throw StateError (
176
+ 'Autofill would not work withuot Autofill value set' );
177
+ } else {
178
+ final AutofillInfo autofillInfo = items! [key] as AutofillInfo ;
179
+ _handleChange (element, autofillInfo);
180
+ }
173
181
}));
174
182
});
175
183
return subscriptions;
176
184
}
177
185
178
- void _handleChange (html.Element domElement, String ? tag) {
179
- EditingState newEditingState =
180
- EditingState .fromDomElement (domElement as html.HtmlElement ? );
186
+ void _handleChange (html.Element domElement, AutofillInfo autofillInfo) {
187
+ EditingState newEditingState = EditingState .fromDomElement (
188
+ domElement as html.HtmlElement ? ,
189
+ textCapitalization: autofillInfo.textCapitalization);
181
190
182
- _sendAutofillEditingState (tag , newEditingState);
191
+ _sendAutofillEditingState (autofillInfo.uniqueIdentifier , newEditingState);
183
192
}
184
193
185
194
/// Sends the 'TextInputClient.updateEditingStateWithTag' message to the framework.
@@ -210,7 +219,8 @@ class AutofillInfo {
210
219
AutofillInfo (
211
220
{required this .editingState,
212
221
required this .uniqueIdentifier,
213
- required this .hint});
222
+ required this .hint,
223
+ required this .textCapitalization});
214
224
215
225
/// The current text and selection state of a text field.
216
226
final EditingState editingState;
@@ -220,14 +230,29 @@ class AutofillInfo {
220
230
/// Used as id of the text field.
221
231
final String uniqueIdentifier;
222
232
233
+ /// Information on how should autofilled text capitalized.
234
+ ///
235
+ /// For example for [TextCapitalization.characters] each letter is converted
236
+ /// to upper case.
237
+ ///
238
+ /// This value is not necessary for autofilling the focused element since
239
+ /// [DefaultTextEditingStrategy._inputConfiguration] already has this
240
+ /// information.
241
+ ///
242
+ /// On the other hand for the multi element forms, for the input elements
243
+ /// other the focused field, we need to use this information.
244
+ final TextCapitalizationUtil textCapitalization;
245
+
223
246
/// Attribute used for autofill.
224
247
///
225
248
/// Used as a guidance to the browser as to the type of information expected
226
249
/// in the field.
227
250
/// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
228
251
final String hint;
229
252
230
- factory AutofillInfo .fromFrameworkMessage (Map <String , dynamic > autofill) {
253
+ factory AutofillInfo .fromFrameworkMessage (Map <String , dynamic > autofill,
254
+ {TextCapitalizationUtil textCapitalization =
255
+ const TextCapitalizationUtil .defaultCapitalization ()}) {
231
256
assert (autofill != null ); // ignore: unnecessary_null_comparison
232
257
final String uniqueIdentifier = autofill['uniqueIdentifier' ]! ;
233
258
final List <dynamic > hintsList = autofill['hints' ];
@@ -236,7 +261,8 @@ class AutofillInfo {
236
261
return AutofillInfo (
237
262
uniqueIdentifier: uniqueIdentifier,
238
263
hint: BrowserAutofillHints .instance.flutterToEngine (hintsList[0 ]),
239
- editingState: editingState);
264
+ editingState: editingState,
265
+ textCapitalization: textCapitalization);
240
266
}
241
267
242
268
void applyToDomElement (html.HtmlElement domElement,
0 commit comments