import 'dart:math'; import 'package:flutter/material.dart'; import 'package:luojigou_thinking_core/luojigou_thinking_core.dart'; class Demo4 extends StatefulWidget { const Demo4({Key? key}) : super(key: key); @override State createState() => _Demo4State(); } class _Demo4State extends State { @override Widget build(BuildContext context) { return Center( child: SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width, child: CustomPaint( painter: _Painter(), ), ), ); } } class _Painter extends CustomPainter { @override void paint(Canvas canvas, Size size) { Paint paint = Paint() ..color = Colors.deepPurple ..style = PaintingStyle.stroke ..strokeWidth = 0.5; final Offset o = Offset(50, 50); final Offset o1 = Offset(200, 400); final Offset o2 = Offset(400, 200); final path = Path(); path.moveTo(o1.dx, o1.dy); path.lineTo(o.dx, o.dy); path.lineTo(o2.dx, o2.dy); canvas.drawPath(path, paint); canvas.drawCircle(PlaneGeometryUtils.origin(o, o1, o2, 40), 40, paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) => false; }