Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18a1f69

Browse files
committed
Add shadow behing floating cursor
1 parent 03b096c commit 18a1f69

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/src/_code_field.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,10 +1611,24 @@ class _CodeFieldFloatingCursorPainter extends _CodeFieldExtraPainter {
16111611
if (_offset == null || _color == Colors.transparent || _color.alpha == 0) {
16121612
return;
16131613
}
1614-
_drawCaret(canvas, _offset!, size);
1614+
_drawFloatingCaret(canvas, _offset!, size);
16151615
}
16161616

1617-
void _drawCaret(Canvas canvas, Offset offset, Size size) {
1617+
void _drawFloatingCaret(Canvas canvas, Offset offset, Size size) {
1618+
final caretRect = RRect.fromRectXY(
1619+
Rect.fromLTWH(offset.dx - _width / 2, offset.dy, _width, _height),
1620+
_width / 2,
1621+
_width / 2,
1622+
);
1623+
final path = Path()..addRRect(caretRect);
1624+
1625+
canvas.drawShadow(
1626+
path,
1627+
Colors.black,
1628+
4.0,
1629+
true,
1630+
);
1631+
16181632
_paint.color = _color;
16191633
canvas.drawRRect(RRect.fromRectXY(Rect.fromLTWH(offset.dx - _width / 2, offset.dy, _width, _height), _width / 2, _width / 2), _paint);
16201634
}

0 commit comments

Comments
 (0)