mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

How to draw a rectangle with corners?

Open magic3584 opened this issue 1 year ago • 2 comments

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.

magic3584 avatar Nov 27 '23 03:11 magic3584

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.

navaronbracke avatar Nov 27 '23 15:11 navaronbracke

https://stackoverflow.com/questions/68964433/how-to-make-a-customised-qr-code-scanner-using-flutter

marab000 avatar Dec 08 '23 06:12 marab000