From 772bd4381a9cce90a30f88e2b76313c357437b75 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Fri, 23 Sep 2022 05:56:00 +0800 Subject: [PATCH] Fix RenderEditable not able to update backgroundCursorColor when the user provides a new one (#112045) Pass through backgroundCursorColor parameter --- .../lib/src/widgets/editable_text.dart | 1 + .../test/widgets/editable_text_test.dart | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 308cbe6947..9399cf5bad 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -4052,6 +4052,7 @@ class _Editable extends MultiChildRenderObjectWidget { ..cursorColor = cursorColor ..startHandleLayerLink = startHandleLayerLink ..endHandleLayerLink = endHandleLayerLink + ..backgroundCursorColor = backgroundCursorColor ..showCursor = showCursor ..forceLine = forceLine ..readOnly = readOnly diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index 201a1c1b91..71bd089d8a 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -262,6 +262,30 @@ void main() { expect(editableText.textHeightBehavior, isNull); }); + testWidgets('when backgroundCursorColor is updated, RenderEditable should be updated', (WidgetTester tester) async { + Widget buildWidget(Color backgroundCursorColor) { + return MediaQuery( + data: const MediaQueryData(), + child: Directionality( + textDirection: TextDirection.ltr, + child: EditableText( + controller: controller, + backgroundCursorColor: backgroundCursorColor, + focusNode: focusNode, + style: textStyle, + cursorColor: cursorColor, + ), + ), + ); + } + + await tester.pumpWidget(buildWidget(Colors.red)); + await tester.pumpWidget(buildWidget(Colors.green)); + + final RenderEditable render = tester.allRenderObjects.whereType().first; + expect(render.backgroundCursorColor, Colors.green); + }); + testWidgets('text keyboard is requested when maxLines is default', (WidgetTester tester) async { await tester.pumpWidget( MediaQuery(