Skip to content

Commit 772bd43

Browse files
authored
Fix RenderEditable not able to update backgroundCursorColor when the user provides a new one (#112045)
Pass through backgroundCursorColor parameter
1 parent a24b50b commit 772bd43

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,7 @@ class _Editable extends MultiChildRenderObjectWidget {
40524052
..cursorColor = cursorColor
40534053
..startHandleLayerLink = startHandleLayerLink
40544054
..endHandleLayerLink = endHandleLayerLink
4055+
..backgroundCursorColor = backgroundCursorColor
40554056
..showCursor = showCursor
40564057
..forceLine = forceLine
40574058
..readOnly = readOnly

packages/flutter/test/widgets/editable_text_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,30 @@ void main() {
262262
expect(editableText.textHeightBehavior, isNull);
263263
});
264264

265+
testWidgets('when backgroundCursorColor is updated, RenderEditable should be updated', (WidgetTester tester) async {
266+
Widget buildWidget(Color backgroundCursorColor) {
267+
return MediaQuery(
268+
data: const MediaQueryData(),
269+
child: Directionality(
270+
textDirection: TextDirection.ltr,
271+
child: EditableText(
272+
controller: controller,
273+
backgroundCursorColor: backgroundCursorColor,
274+
focusNode: focusNode,
275+
style: textStyle,
276+
cursorColor: cursorColor,
277+
),
278+
),
279+
);
280+
}
281+
282+
await tester.pumpWidget(buildWidget(Colors.red));
283+
await tester.pumpWidget(buildWidget(Colors.green));
284+
285+
final RenderEditable render = tester.allRenderObjects.whereType<RenderEditable>().first;
286+
expect(render.backgroundCursorColor, Colors.green);
287+
});
288+
265289
testWidgets('text keyboard is requested when maxLines is default', (WidgetTester tester) async {
266290
await tester.pumpWidget(
267291
MediaQuery(

0 commit comments

Comments
 (0)