Commit cdc68a73 authored by Roberto Scaramuzzi's avatar Roberto Scaramuzzi Committed by Ian Hickson

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
parent 2329cb7e
...@@ -60,6 +60,7 @@ class TextFormField extends FormField<String> { ...@@ -60,6 +60,7 @@ class TextFormField extends FormField<String> {
bool autofocus: false, bool autofocus: false,
bool obscureText: false, bool obscureText: false,
bool autocorrect: true, bool autocorrect: true,
bool autovalidate: false,
bool maxLengthEnforced: true, bool maxLengthEnforced: true,
int maxLines: 1, int maxLines: 1,
int maxLength, int maxLength,
...@@ -74,6 +75,7 @@ class TextFormField extends FormField<String> { ...@@ -74,6 +75,7 @@ class TextFormField extends FormField<String> {
assert(autofocus != null), assert(autofocus != null),
assert(obscureText != null), assert(obscureText != null),
assert(autocorrect != null), assert(autocorrect != null),
assert(autovalidate != null),
assert(maxLengthEnforced != null), assert(maxLengthEnforced != null),
assert(maxLines == null || maxLines > 0), assert(maxLines == null || maxLines > 0),
assert(maxLength == null || maxLength > 0), assert(maxLength == null || maxLength > 0),
...@@ -82,6 +84,7 @@ class TextFormField extends FormField<String> { ...@@ -82,6 +84,7 @@ class TextFormField extends FormField<String> {
initialValue: controller != null ? controller.text : (initialValue ?? ''), initialValue: controller != null ? controller.text : (initialValue ?? ''),
onSaved: onSaved, onSaved: onSaved,
validator: validator, validator: validator,
autovalidate: autovalidate,
builder: (FormFieldState<String> field) { builder: (FormFieldState<String> field) {
final _TextFormFieldState state = field; final _TextFormFieldState state = field;
final InputDecoration effectiveDecoration = (decoration ?? const InputDecoration()) final InputDecoration effectiveDecoration = (decoration ?? const InputDecoration())
......
...@@ -49,4 +49,27 @@ void main() { ...@@ -49,4 +49,27 @@ void main() {
await tester.pump(); await tester.pump();
expect(_called, true); 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);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment