Files
fengshui_compass/lib/components/cross_paint.dart

36 lines
954 B
Dart
Raw Normal View History

2022-06-27 17:37:25 +08:00
import 'package:flutter/material.dart';
class CrossPaint extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.transparent,
alignment: Alignment.center,
child: CustomPaint(
// 使用CustomPaint 背景画板
painter: MyPainter(),
),
);
}
}
class MyPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
// 创建画笔
final Paint paintLine = Paint()
2022-07-05 09:46:51 +08:00
..color = Colors.white
2022-06-27 17:37:25 +08:00
..strokeWidth = 2;
// 绘制线
2022-07-05 09:46:51 +08:00
canvas.drawLine(const Offset(-400, 0), const Offset(400, 0), paintLine);
canvas.drawLine(const Offset(0, 500), const Offset(0, -440), paintLine);
2022-06-27 17:37:25 +08:00
// 创建画笔
// final Paint paintPoint = Paint()..color = Colors.red;
// 绘制圆点
// canvas.drawCircle(Offset(0, 0), 10, paintPoint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => false;
}