Fix RenderEditable not able to update backgroundCursorColor when the user provides a new one (#112045)

Pass through backgroundCursorColor parameter
This commit is contained in:
fzyzcjy
2022-09-23 05:56:00 +08:00
committed by GitHub
parent a24b50ba8f
commit 772bd4381a
2 changed files with 25 additions and 0 deletions

View File

@@ -4052,6 +4052,7 @@ class _Editable extends MultiChildRenderObjectWidget {
..cursorColor = cursorColor
..startHandleLayerLink = startHandleLayerLink
..endHandleLayerLink = endHandleLayerLink
..backgroundCursorColor = backgroundCursorColor
..showCursor = showCursor
..forceLine = forceLine
..readOnly = readOnly

View File

@@ -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<RenderEditable>().first;
expect(render.backgroundCursorColor, Colors.green);
});
testWidgets('text keyboard is requested when maxLines is default', (WidgetTester tester) async {
await tester.pumpWidget(
MediaQuery(