From 8b6b3b62c17e1d9ae0b7d3cc1cffee38209cee23 Mon Sep 17 00:00:00 2001 From: Prerak Mann <31154435+mannprerak2@users.noreply.github.com> Date: Tue, 14 Jan 2020 06:38:01 +0530 Subject: [PATCH] Passes scrollPhysics (#48342) --- .../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 1c9c411a29..85beb44ea4 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -124,6 +124,7 @@ class TextFormField extends FormField { EdgeInsets scrollPadding = const EdgeInsets.all(20.0), bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter, + ScrollPhysics scrollPhysics, }) : assert(initialValue == null || controller == null), assert(textAlign != null), assert(autofocus != null), @@ -201,6 +202,7 @@ class TextFormField extends FormField { cursorRadius: cursorRadius, cursorColor: cursorColor, scrollPadding: scrollPadding, + scrollPhysics: scrollPhysics, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter, diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index 6fe2fcad8d..7114a74bc4 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -32,6 +32,28 @@ void main() { expect(textFieldWidget.textAlign, alignment); }); + testWidgets('Passes scrollPhysics to underlying TextField', (WidgetTester tester) async { + const ScrollPhysics scrollPhysics = ScrollPhysics(); + + await tester.pumpWidget( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( + scrollPhysics: scrollPhysics, + ), + ), + ), + ), + ); + + final Finder textFieldFinder = find.byType(TextField); + expect(textFieldFinder, findsOneWidget); + + final TextField textFieldWidget = tester.widget(textFieldFinder); + expect(textFieldWidget.scrollPhysics, scrollPhysics); + }); + testWidgets('Passes textAlignVertical to underlying TextField', (WidgetTester tester) async { const TextAlignVertical textAlignVertical = TextAlignVertical.bottom;