Add autofill support for TextFormField (#57332)

This commit is contained in:
Pedro Massango 2020-05-18 10:32:02 +01:00 committed by GitHub
parent e8a7dc466b
commit 07f9563dac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -174,6 +174,7 @@ class TextFormField extends FormField<String> {
bool enableInteractiveSelection = true,
InputCounterWidgetBuilder buildCounter,
ScrollPhysics scrollPhysics,
Iterable<String> autofillHints,
}) : assert(initialValue == null || controller == null),
assert(textAlign != null),
assert(autofocus != null),
@ -257,6 +258,7 @@ class TextFormField extends FormField<String> {
keyboardAppearance: keyboardAppearance,
enableInteractiveSelection: enableInteractiveSelection,
buildCounter: buildCounter,
autofillHints: autofillHints,
);
},
);

View file

@ -425,4 +425,21 @@ void main() {
expect(find.text('initialValue'), findsNothing);
expect(find.text('changedValue'), findsOneWidget);
});
testWidgets('autofillHints is passed to super', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Center(
child: TextFormField(
autofillHints: const <String>[AutofillHints.countryName],
),
),
),
),
);
final TextField widget = tester.widget(find.byType(TextField));
expect(widget.autofillHints, equals(const <String>[AutofillHints.countryName]));
});
}