Im using MLKit and custom painter to dynamically draw on screen when it detects something, however I would like to be able to show an image within that polygon resized to fit within the shape.
It seems there is UI.Image which can be used along with the canvass function drawImage, but that doesn't seem to support polygons.
Any help or suggestions would be appreciated.
class MyPainter extends CustomPainter {
final Offset firstPoint;
final Offset secondPoint;
final Offset thirdPoint;
final Offset fourthPoint;
MyPainter(
this.firstPoint, this.secondPoint, this.thirdPoint, this.fourthPoint);
@override
void paint(Canvas canvas, Size size) {
var paint = Paint()
..color = Color(0xff638965)
..style = PaintingStyle.fill;
canvas.drawPath(
Path()
..addPolygon([
firstPoint,
secondPoint,
thirdPoint,
fourthPoint,
], true),
paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}