Skip to content

Commit fa2fd11

Browse files
knezzzxster
authored andcommitted
Update CupertinoTextField (flutter#29008)
1 parent 475d93a commit fa2fd11

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/flutter/lib/src/cupertino/text_field.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with AutomaticK
672672
final CupertinoThemeData themeData = CupertinoTheme.of(context);
673673
final TextStyle textStyle = themeData.textTheme.textStyle.merge(widget.style);
674674
final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.brightness;
675+
final Color cursorColor = widget.cursorColor ?? themeData.primaryColor;
675676

676677
final Widget paddedEditable = Padding(
677678
padding: widget.padding,
@@ -702,7 +703,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with AutomaticK
702703
rendererIgnoresPointer: true,
703704
cursorWidth: widget.cursorWidth,
704705
cursorRadius: widget.cursorRadius,
705-
cursorColor: themeData.primaryColor,
706+
cursorColor: cursorColor,
706707
cursorOpacityAnimates: true,
707708
cursorOffset: cursorOffset,
708709
paintCursorAboveText: true,

packages/flutter/test/cupertino/text_field_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,4 +1918,20 @@ void main() {
19181918
await tester.pump();
19191919
expect(renderEditable.cursorColor, const Color(0xFFF44336));
19201920
});
1921+
1922+
testWidgets('cursor can override color from theme', (WidgetTester tester) async {
1923+
await tester.pumpWidget(
1924+
const CupertinoApp(
1925+
theme: CupertinoThemeData(),
1926+
home: Center(
1927+
child: CupertinoTextField(
1928+
cursorColor: Color(0xFFF44336),
1929+
),
1930+
),
1931+
),
1932+
);
1933+
1934+
final EditableText editableText = tester.firstWidget(find.byType(EditableText));
1935+
expect(editableText.cursorColor, const Color(0xFFF44336));
1936+
});
19211937
}

0 commit comments

Comments
 (0)