Skip to content

Commit 703ae77

Browse files
authored
feat: Add onTapAlwaysCalled in TextFormField (flutter#140089)
Add onTapAlwaysCalled in TextFormField *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
1 parent ea1e2df commit 703ae77

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/flutter/lib/src/material/text_form_field.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class TextFormField extends FormField<String> {
134134
int? maxLength,
135135
this.onChanged,
136136
GestureTapCallback? onTap,
137+
bool onTapAlwaysCalled = false,
137138
TapRegionCallback? onTapOutside,
138139
VoidCallback? onEditingComplete,
139140
ValueChanged<String>? onFieldSubmitted,
@@ -231,6 +232,7 @@ class TextFormField extends FormField<String> {
231232
maxLength: maxLength,
232233
onChanged: onChangedHandler,
233234
onTap: onTap,
235+
onTapAlwaysCalled: onTapAlwaysCalled,
234236
onTapOutside: onTapOutside,
235237
onEditingComplete: onEditingComplete,
236238
onSubmitted: onFieldSubmitted,

packages/flutter/test/material/text_form_field_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,26 @@ void main() {
15121512
expect(textFieldWidget.dragStartBehavior, dragStartBehavior);
15131513
});
15141514

1515+
testWidgetsWithLeakTracking('Passes onTapAlwaysCalled to onTapAlwaysCalled TextField', (WidgetTester tester) async {
1516+
await tester.pumpWidget(
1517+
MaterialApp(
1518+
home: Material(
1519+
child: Center(
1520+
child: TextFormField(
1521+
onTapAlwaysCalled: true,
1522+
),
1523+
),
1524+
),
1525+
),
1526+
);
1527+
1528+
final Finder textFieldFinder = find.byType(TextField);
1529+
expect(textFieldFinder, findsOneWidget);
1530+
1531+
final TextField textFieldWidget = tester.widget(textFieldFinder);
1532+
expect(textFieldWidget.onTapAlwaysCalled, isTrue);
1533+
});
1534+
15151535
testWidgetsWithLeakTracking('Error color for cursor while validating', (WidgetTester tester) async {
15161536
const Color themeErrorColor = Color(0xff111111);
15171537
const Color errorStyleColor = Color(0xff777777);

0 commit comments

Comments
 (0)