mobile_scanner
mobile_scanner copied to clipboard
How to draw a rectangle with corners?
List<Offset> offsetList = Barcode.corners;
@override
void paint(Canvas canvas, Size size) {
Offset topLeft = offsetList[0];
Offset topRight = offsetList[1];
Offset bottomRight = offsetList[2];
Offset bottomLeft = offsetList[3];
Paint paint = Paint()
..color = Colors.blue
..style = PaintingStyle.fill;
canvas.drawRect(Rect.fromPoints(topLeft, bottomRight), paint);
}
Looks like the rectangle has a wrong place and size.
You should be using the centerpoint as your anchor point, now you use the origin point of the canvas.
Also, is the first point really the top left?
This kind of question should be asked on stackoverflow, since this is not a bug of the package.
https://stackoverflow.com/questions/68964433/how-to-make-a-customised-qr-code-scanner-using-flutter