Created
April 18, 2024 09:45
-
-
Save mirkancal/5f97c7eb1efdff71467b077dc958534a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class QRCornerPainter extends CustomPainter { | |
@override | |
void paint(Canvas canvas, Size size) { | |
final paint = Paint() | |
..color = Colors.white | |
..style = PaintingStyle.fill; | |
final cornerLength = size.width * 0.1; | |
final cornerThickness = cornerLength * 0.2; | |
// Top-left corner | |
canvas.drawRect(Rect.fromLTWH(0, 0, cornerLength, cornerThickness), paint); | |
canvas.drawRect(Rect.fromLTWH(0, 0, cornerThickness, cornerLength), paint); | |
// Top-right corner | |
canvas.drawRect( | |
Rect.fromLTWH( | |
size.width - cornerLength, 0, cornerLength, cornerThickness), | |
paint); | |
canvas.drawRect( | |
Rect.fromLTWH( | |
size.width - cornerThickness, 0, cornerThickness, cornerLength), | |
paint); | |
// Bottom-left corner | |
canvas.drawRect( | |
Rect.fromLTWH( | |
0, size.height - cornerThickness, cornerLength, cornerThickness), | |
paint); | |
canvas.drawRect( | |
Rect.fromLTWH( | |
0, size.height - cornerLength, cornerThickness, cornerLength), | |
paint); | |
// Bottom-right corner | |
canvas.drawRect( | |
Rect.fromLTWH(size.width - cornerLength, size.height - cornerThickness, | |
cornerLength, cornerThickness), | |
paint); | |
canvas.drawRect( | |
Rect.fromLTWH(size.width - cornerThickness, size.height - cornerLength, | |
cornerThickness, cornerLength), | |
paint); | |
} | |
@override | |
bool shouldRepaint(covariant CustomPainter oldDelegate) { | |
return false; | |
} | |
} |
Author
mirkancal
commented
Apr 18, 2024
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment