Created
February 1, 2022 09:52
-
-
Save arif-pandu/0c59133c118e2923da274af1e9b45bf6 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
Container( | |
height: 2*50, //100 | |
width : sqrt(3)* 50, //86.602 | |
child: CustomPaint( | |
painter: HexagonPainter(), | |
child; Container(), | |
), | |
), | |
class HexagonPainter extends CustomPainter { | |
@override | |
void paint(Canvas canvas, Size size) { | |
// We'll draw here | |
final paint = Paint(); | |
paint.color = Colors.teal; | |
paint.style = PaintingStyle.fill; | |
final path = Path(); | |
path.moveTo(size.width * 0.5, size.height * 0); | |
path.lineTo(size.width * 1, size.height * 1 / 4); | |
path.lineTo(size.width * 1, size.height * 3 / 4); | |
path.lineTo(size.width * 0.5, size.height * 1); | |
path.lineTo(size.width * 0, size.height * 3 / 4); | |
path.lineTo(size.width * 0, size.height * 1 / 4); | |
path.close(); | |
canvas.drawPath(path, paint); | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment