diagonalpainter.dart 741 B

123456789101112131415161718192021222324252627282930
  1. import 'package:flutter/material.dart';
  2. import 'package:flyinsonolite/infrastructure/scale.dart';
  3. class DiagonalPainter extends CustomPainter {
  4. final Color color;
  5. DiagonalPainter(this.color);
  6. @override
  7. void paint(Canvas canvas, Size size) {
  8. final paint = Paint()
  9. ..color = color
  10. ..style = PaintingStyle.fill
  11. ..strokeWidth = 2.s;
  12. final path = Path()
  13. ..moveTo(0, 0)
  14. ..lineTo(64.s, 64.s)
  15. ..lineTo(64.s, 8.s)
  16. ..quadraticBezierTo(64.s, 0, 56.s, 0)
  17. ..lineTo(0, 0)
  18. ..close();
  19. canvas.drawPath(path, paint);
  20. }
  21. @override
  22. bool shouldRepaint(covariant DiagonalPainter oldDelegate) {
  23. ///此处可以设置颜色动态值
  24. return oldDelegate.color != color;
  25. }
  26. }