mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
2329cb7ec8
commit
cdc68a73e6
@ -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())
|
||||
|
||||
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user