From 703ae778828c9230b0e079c6deb4ab84be4c0f1f Mon Sep 17 00:00:00 2001 From: lsaudon Date: Fri, 15 Dec 2023 00:05:54 +0100 Subject: [PATCH] feat: Add onTapAlwaysCalled in TextFormField (#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].* --- .../lib/src/material/text_form_field.dart | 2 ++ .../test/material/text_form_field_test.dart | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index f4fa0b5750..87e92d58dc 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -134,6 +134,7 @@ class TextFormField extends FormField { int? maxLength, this.onChanged, GestureTapCallback? onTap, + bool onTapAlwaysCalled = false, TapRegionCallback? onTapOutside, VoidCallback? onEditingComplete, ValueChanged? onFieldSubmitted, @@ -231,6 +232,7 @@ class TextFormField extends FormField { maxLength: maxLength, onChanged: onChangedHandler, onTap: onTap, + onTapAlwaysCalled: onTapAlwaysCalled, onTapOutside: onTapOutside, onEditingComplete: onEditingComplete, onSubmitted: onFieldSubmitted, diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index e056924142..7d2a6755a5 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -1512,6 +1512,26 @@ void main() { expect(textFieldWidget.dragStartBehavior, dragStartBehavior); }); + testWidgetsWithLeakTracking('Passes onTapAlwaysCalled to onTapAlwaysCalled TextField', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( + onTapAlwaysCalled: true, + ), + ), + ), + ), + ); + + final Finder textFieldFinder = find.byType(TextField); + expect(textFieldFinder, findsOneWidget); + + final TextField textFieldWidget = tester.widget(textFieldFinder); + expect(textFieldWidget.onTapAlwaysCalled, isTrue); + }); + testWidgetsWithLeakTracking('Error color for cursor while validating', (WidgetTester tester) async { const Color themeErrorColor = Color(0xff111111); const Color errorStyleColor = Color(0xff777777);