import 'package:flutter/material.dart';

class Cubo extends StatelessWidget {
  final double width;
  const Cubo({Key? key, required this.width}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width / 4,
      height: width / 8,
      child: CustomPaint(
        painter: _Cubo(),
      ),
      padding: const EdgeInsets.all(2.0),
    );
  }
}

class _Cubo extends CustomPainter{
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint();

    paint.color = Colors.black;
    paint.style = PaintingStyle.stroke;
    paint.strokeWidth = 2.0;

    final path = Path();

    final x = size.width / 8;
    final y = size.height / 5;

    path.moveTo(x * 3, 0);
    path.lineTo(0, y);
    path.lineTo(x * 5, y * 2);
    path.lineTo(size.width, y);
    path.lineTo(x * 3, 0);

    path.moveTo(x * 5, y * 2);
    path.lineTo(x * 5, size.height);
    path.lineTo(0, y * 4);
    path.lineTo(0, y);

    path.moveTo(x * 5, size.height);
    path.lineTo(size.width, y * 4);
    path.lineTo(size.width, y);

    canvas.drawPath(path, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return true;
  }
}

