mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add onTapOutside to TextFormField (#108629)
This commit is contained in:
parent
db3b1411b7
commit
5532775b19
@ -125,6 +125,7 @@ class TextFormField extends FormField<String> {
|
||||
int? maxLength,
|
||||
ValueChanged<String>? onChanged,
|
||||
GestureTapCallback? onTap,
|
||||
TapRegionCallback? onTapOutside,
|
||||
VoidCallback? onEditingComplete,
|
||||
ValueChanged<String>? onFieldSubmitted,
|
||||
super.onSaved,
|
||||
@ -216,6 +217,7 @@ class TextFormField extends FormField<String> {
|
||||
maxLength: maxLength,
|
||||
onChanged: onChangedHandler,
|
||||
onTap: onTap,
|
||||
onTapOutside: onTapOutside,
|
||||
onEditingComplete: onEditingComplete,
|
||||
onSubmitted: onFieldSubmitted,
|
||||
inputFormatters: inputFormatters,
|
||||
|
@ -728,6 +728,36 @@ void main() {
|
||||
expect(tapCount, 3);
|
||||
});
|
||||
|
||||
testWidgets('onTapOutside is called upon tap outside', (WidgetTester tester) async {
|
||||
int tapOutsideCount = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const Text('Outside'),
|
||||
TextFormField(
|
||||
onTapOutside: (PointerEvent event) {
|
||||
tapOutsideCount += 1;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump(); // Wait for autofocus to take effect.
|
||||
|
||||
expect(tapOutsideCount, 0);
|
||||
await tester.tap(find.byType(TextFormField));
|
||||
await tester.tap(find.text('Outside'));
|
||||
await tester.tap(find.text('Outside'));
|
||||
await tester.tap(find.text('Outside'));
|
||||
expect(tapOutsideCount, 3);
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/54472.
|
||||
testWidgets('reset resets the text fields value to the initialValue', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
|
Loading…
Reference in New Issue
Block a user