From 6901cd4625292b303040f1a9fda95e564a9adb6a Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Tue, 11 Dec 2018 10:42:10 -0800 Subject: [PATCH] TextFormField cursor params (#24635) * cursor fields on textformfield * Test pass-through of cursor properties --- .../lib/src/material/text_form_field.dart | 6 ++++ .../test/material/text_form_field_test.dart | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 4a4ec2c85b..b05852370d 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -95,6 +95,9 @@ class TextFormField extends FormField { FormFieldValidator validator, List inputFormatters, bool enabled = true, + double cursorWidth = 2.0, + Radius cursorRadius, + Color cursorColor, Brightness keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), bool enableInteractiveSelection = true, @@ -141,6 +144,9 @@ class TextFormField extends FormField { onSubmitted: onFieldSubmitted, inputFormatters: inputFormatters, enabled: enabled, + cursorWidth: cursorWidth, + cursorRadius: cursorRadius, + cursorColor: cursorColor, scrollPadding: scrollPadding, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index 4ad6c40026..c40af9154c 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -71,6 +71,34 @@ void main() { expect(textFieldWidget.onEditingComplete, onEditingComplete); }); + testWidgets('Passes cursor attributes to underlying TextField', (WidgetTester tester) async { + const double cursorWidth = 3.14; + const Radius cursorRadius = Radius.circular(4); + const Color cursorColor = Colors.purple; + + await tester.pumpWidget( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( + cursorWidth: cursorWidth, + cursorRadius: cursorRadius, + cursorColor: cursorColor, + ), + ), + ), + ), + ); + + final Finder textFieldFinder = find.byType(TextField); + expect(textFieldFinder, findsOneWidget); + + final TextField textFieldWidget = tester.widget(textFieldFinder); + expect(textFieldWidget.cursorWidth, cursorWidth); + expect(textFieldWidget.cursorRadius, cursorRadius); + expect(textFieldWidget.cursorColor, cursorColor); + }); + testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async { bool _called = false;