fluffychat/lib/pangea/message_token_text/dotted_border_painter.dart
ggurdin 592aa43089
2202 positioning to dos in reading assistance (#2214)
* chore: move toolbar buttons above reading assistance input bar

* chore: positioning on message relative to header and footer / positioning of tooltip between message and header

* chore: update inline tooltip color

* chore: animate reading assistance input bar height
2025-03-25 14:40:18 -04:00

48 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
class DottedBorderPainter extends CustomPainter {
final Color color;
final double strokeWidth;
final double dashWidth;
final double dashSpace;
final BorderRadius borderRadius;
DottedBorderPainter({
required this.color,
this.strokeWidth = 2.0,
this.dashWidth = 4.0,
this.dashSpace = 4.0,
required this.borderRadius,
});
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke;
final path = Path()
..addRRect(
borderRadius.toRRect(Rect.fromLTWH(0, 0, size.width, size.height)),
);
final dashPath = Path();
final pathMetrics = path.computeMetrics();
for (final pathMetric in pathMetrics) {
double distance = 0.0;
while (distance < pathMetric.length) {
final segment = pathMetric.extractPath(distance, distance + dashWidth);
dashPath.addPath(segment, Offset.zero);
distance += dashWidth + dashSpace;
}
}
canvas.drawPath(dashPath, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}