add ontap to textformfield (#37403)
This commit is contained in:
parent
873de56228
commit
5df17acb1f
@ -100,6 +100,7 @@ class TextFormField extends FormField<String> {
|
||||
bool expands = false,
|
||||
int maxLength,
|
||||
ValueChanged<String> onChanged,
|
||||
GestureTapCallback onTap,
|
||||
VoidCallback onEditingComplete,
|
||||
ValueChanged<String> onFieldSubmitted,
|
||||
FormFieldSetter<String> onSaved,
|
||||
@ -175,6 +176,7 @@ class TextFormField extends FormField<String> {
|
||||
expands: expands,
|
||||
maxLength: maxLength,
|
||||
onChanged: onChangedHandler,
|
||||
onTap: onTap,
|
||||
onEditingComplete: onEditingComplete,
|
||||
onSubmitted: onFieldSubmitted,
|
||||
inputFormatters: inputFormatters,
|
||||
|
@ -280,4 +280,31 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
|
||||
});
|
||||
|
||||
testWidgets('onTap is called upon tap', (WidgetTester tester) async {
|
||||
int tapCount = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
onTap: () {
|
||||
tapCount += 1;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tapCount, 0);
|
||||
await tester.tap(find.byType(TextField));
|
||||
// Wait a bit so they're all single taps and not double taps.
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
await tester.tap(find.byType(TextField));
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
await tester.tap(find.byType(TextField));
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
expect(tapCount, 3);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user