From 859aec592fdd5d806e8042b5e43ab52d40c8dad3 Mon Sep 17 00:00:00 2001 From: Chinmoy <57670338+chinmoy12c@users.noreply.github.com> Date: Tue, 9 Feb 2021 23:31:07 +0530 Subject: [PATCH] Added scrollController property to TextFormField (#75169) --- .../lib/src/material/text_form_field.dart | 2 ++ .../test/material/text_form_field_test.dart | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 1ac21f3269..ce0c4e425d 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -193,6 +193,7 @@ class TextFormField extends FormField { ScrollPhysics? scrollPhysics, Iterable? autofillHints, AutovalidateMode? autovalidateMode, + ScrollController? scrollController, }) : assert(initialValue == null || controller == null), assert(textAlign != null), assert(autofocus != null), @@ -291,6 +292,7 @@ class TextFormField extends FormField { selectionControls: selectionControls, buildCounter: buildCounter, autofillHints: autofillHints, + scrollController: scrollController, ); }, ); diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index d741bdab73..f67b31f66a 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -727,4 +727,26 @@ void main() { final TextDirection textDirection = Directionality.of(context); expect(textDirection, TextDirection.rtl); }); + + testWidgets('Passes scrollController to underlying TextField', (WidgetTester tester) async { + final ScrollController scrollController = ScrollController(); + + await tester.pumpWidget( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( + scrollController: scrollController, + ), + ), + ), + ), + ); + + final Finder textFieldFinder = find.byType(TextField); + expect(textFieldFinder, findsOneWidget); + + final TextField textFieldWidget = tester.widget(textFieldFinder); + expect(textFieldWidget.scrollController, scrollController); + }); }