clipPath method
Clip this image with path
, use a Canvas render
Implementation
Future<void> clipPath(Path path, {bool doAntiAlias = true}) async {
await _lockWrite();
Rect boundary = path.getBounds();
PictureRecorder pr = PictureRecorder();
Canvas canvas = Canvas(pr);
Image image = await getImage();
canvas.clipPath(path, doAntiAlias: doAntiAlias);
canvas.drawImage(image, Offset.zero, Paint());
canvas.save();
Picture picture = pr.endRecording();
image = await picture.toImage(min(boundary.width.round(), _width),
min(boundary.height.round(), _height));
_buffer = (await image.toByteData(format: ImageByteFormat.rawRgba))!
.buffer
.asByteData();
_width = image.width;
_height = image.height;
_unLock();
}