Skip to content

Instantly share code, notes, and snippets.

@arif-pandu
Created February 1, 2022 09:52
Show Gist options
  • Save arif-pandu/0c59133c118e2923da274af1e9b45bf6 to your computer and use it in GitHub Desktop.
Save arif-pandu/0c59133c118e2923da274af1e9b45bf6 to your computer and use it in GitHub Desktop.
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