From 07f9563dac690aa03c2d62abf0d6bb1d4d5b12aa Mon Sep 17 00:00:00 2001 From: Pedro Massango Date: Mon, 18 May 2020 10:32:02 +0100 Subject: [PATCH] Add autofill support for TextFormField (#57332) --- .../lib/src/material/text_form_field.dart | 2 ++ .../test/material/text_form_field_test.dart | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 72955b49639..70bd9907ac0 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -174,6 +174,7 @@ class TextFormField extends FormField { bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter, ScrollPhysics scrollPhysics, + Iterable autofillHints, }) : assert(initialValue == null || controller == null), assert(textAlign != null), assert(autofocus != null), @@ -257,6 +258,7 @@ class TextFormField extends FormField { keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter, + autofillHints: autofillHints, ); }, ); diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index bc7c9dbbde4..0cd68ebd090 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -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 [AutofillHints.countryName], + ), + ), + ), + ), + ); + + final TextField widget = tester.widget(find.byType(TextField)); + expect(widget.autofillHints, equals(const [AutofillHints.countryName])); + }); }