Unverified Commit 5df17acb authored by chunhtai's avatar chunhtai Committed by GitHub

add ontap to textformfield (#37403)

parent 873de562
...@@ -100,6 +100,7 @@ class TextFormField extends FormField<String> { ...@@ -100,6 +100,7 @@ class TextFormField extends FormField<String> {
bool expands = false, bool expands = false,
int maxLength, int maxLength,
ValueChanged<String> onChanged, ValueChanged<String> onChanged,
GestureTapCallback onTap,
VoidCallback onEditingComplete, VoidCallback onEditingComplete,
ValueChanged<String> onFieldSubmitted, ValueChanged<String> onFieldSubmitted,
FormFieldSetter<String> onSaved, FormFieldSetter<String> onSaved,
...@@ -175,6 +176,7 @@ class TextFormField extends FormField<String> { ...@@ -175,6 +176,7 @@ class TextFormField extends FormField<String> {
expands: expands, expands: expands,
maxLength: maxLength, maxLength: maxLength,
onChanged: onChangedHandler, onChanged: onChangedHandler,
onTap: onTap,
onEditingComplete: onEditingComplete, onEditingComplete: onEditingComplete,
onSubmitted: onFieldSubmitted, onSubmitted: onFieldSubmitted,
inputFormatters: inputFormatters, inputFormatters: inputFormatters,
......
...@@ -280,4 +280,31 @@ void main() { ...@@ -280,4 +280,31 @@ void main() {
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); 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);
});
} }
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