dashed_painter 1.0.0 copy "dashed_painter: ^1.0.0" to clipboard
dashed_painter: ^1.0.0 copied to clipboard

A simple Flutter plugin to draw dashed lines and shapes on canvas easily.

🖌️ dashed_painter #

dashed_painter là một plugin Flutter giúp bạn vẽ đường nét đứt (dash lines)đường chấm - gạch (dot-dash) một cách đơn giản trên Canvas.
Thích hợp dùng trong CustomPainter, Decoration, hoặc bất kỳ nơi nào sử dụng đối tượng Canvas.


🚀 Cài đặt #

Thêm vào file pubspec.yaml:

dependencies:
  flutter_dash_painter: ^1.0.0

# hoặc
flutter pub add dashed_painter

Sau đó, chạy lệnh sau để cài đặt package:

flutter pub get

🎨 Cách sử dụng #

  1. Dùng trong CustomPainter
class MyDashedLinePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()
      ..color = Colors.blue
      ..strokeWidth = 2
      ..style = PaintingStyle.stroke;

    final path = Path()
      ..moveTo(0, 0)
      ..lineTo(size.width, 0);

    const DashPainter(span: 4, step: 8).paint(canvas, path, paint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}
  1. Dùng trong Decoration
Container(
  width: 200,
  height: 200,
  decoration: BoxDecoration(
    border: Border.all(
      color: Colors.blue,
      width: 2,
    ),
    borderRadius: BorderRadius.circular(20),
    decoration: const DashDecoration(
      span: 4,
      step: 8,
    ),
  ),
)

✨ Tính năng

✅ Vẽ đường nét đứt (dashed line)

✅ Vẽ đường chấm - gạch (dot-dash)

✅ Vẽ đường nét đứt trên hình học bất kỳ (path)

✅ Vẽ đường nét đứt trên hình học phức tạp (complex path)

✅ Tùy chỉnh độ dài nét (step), khoảng trắng (span)

✅ Hỗ trợ gradient với DashDecoration

✅ Dễ dùng, không cần widget mới

🧩 API DashedPainter

Thuộc tính Mô tả Kiểu Mặc định
span Độ dài khoảng trắng giữa các nét double 4.0
step Độ dài nét vẽ (mỗi đoạn) double 9.0
pointCount Số chấm trong mỗi đoạn int 0
pointWidth Độ dài mỗi chấm nếu dùng pointCount > 0 double 2.0

🧱 API DashDecoration Tất cả thuộc tính của DashPainter +:

Thuộc tính Mô tả Kiểu
radius Bo góc hình chữ nhật Radius?
gradient Gradient màu viền (SweepGradient, v.v.) Gradient?

📂 Thư mục mẫu

dashed_painter/
├── lib/
│   └── dashed_painter.dart
├── example/
│   └── main.dart
├── README.md
├── LICENSE
└── pubspec.yaml

📝 Giấy phép #

dashed_painter được cấp phép theo giấy phép MIT.

2
likes
0
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

A simple Flutter plugin to draw dashed lines and shapes on canvas easily.

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on dashed_painter

Packages that implement dashed_painter