import 'package:flutter/material.dart'; class DashedLine extends StatelessWidget { final double height; final Color color; final double dashWidth; final double dashSpace; const DashedLine({ super.key, this.height = 1, this.color = Colors.black, this.dashWidth = 5, this.dashSpace = 3, }); @override Widget build(BuildContext context) { return CustomPaint( size: Size(double.infinity, height), painter: _DashedLinePainter( color: color, dashWidth: dashWidth, dashSpace: dashSpace, strokeWidth: height, ), ); } } class _DashedLinePainter extends CustomPainter { final Color color; final double dashWidth; final double dashSpace; final double strokeWidth; _DashedLinePainter({ required this.color, required this.dashWidth, required this.dashSpace, required this.strokeWidth, }); @override void paint(Canvas canvas, Size size) { final paint = Paint() ..color = color ..strokeWidth = strokeWidth; double startX = 0; while (startX < size.width) { canvas.drawLine( Offset(startX, 0), Offset(startX + dashWidth, 0), paint, ); startX += dashWidth + dashSpace; } } @override bool shouldRepaint(covariant CustomPainter oldDelegate) => false; }