Update text_form_field.dart (#15843)

* Update text_form_field.dart

* Update text_form_field_test.dart

* Update text_form_field_test.dart

* Update text_form_field_test.dart
This commit is contained in:
Roberto Scaramuzzi 2018-04-09 13:43:43 -07:00 committed by Ian Hickson
parent 2329cb7ec8
commit cdc68a73e6
2 changed files with 26 additions and 0 deletions

View File

@ -60,6 +60,7 @@ class TextFormField extends FormField<String> {
bool autofocus: false,
bool obscureText: false,
bool autocorrect: true,
bool autovalidate: false,
bool maxLengthEnforced: true,
int maxLines: 1,
int maxLength,
@ -74,6 +75,7 @@ class TextFormField extends FormField<String> {
assert(autofocus != null),
assert(obscureText != null),
assert(autocorrect != null),
assert(autovalidate != null),
assert(maxLengthEnforced != null),
assert(maxLines == null || maxLines > 0),
assert(maxLength == null || maxLength > 0),
@ -82,6 +84,7 @@ class TextFormField extends FormField<String> {
initialValue: controller != null ? controller.text : (initialValue ?? ''),
onSaved: onSaved,
validator: validator,
autovalidate: autovalidate,
builder: (FormFieldState<String> field) {
final _TextFormFieldState state = field;
final InputDecoration effectiveDecoration = (decoration ?? const InputDecoration())

View File

@ -49,4 +49,27 @@ void main() {
await tester.pump();
expect(_called, true);
});
testWidgets('autovalidate is passed to super', (WidgetTester tester) async {
int _validateCalled = 0;
await tester.pumpWidget(
new MaterialApp(
home: new Material(
child: new Center(
child: new TextFormField(
autovalidate: true,
validator: (String value) { _validateCalled++; return null; },
),
),
),
),
);
expect(_validateCalled, 1);
await tester.showKeyboard(find.byType(TextField));
await tester.enterText(find.byType(TextField), 'a');
await tester.pump();
expect(_validateCalled, 2);
});
}