croppedBitmap method
Returns the bitmap cropped with the current crop rectangle.
You can provide the quality used in the resizing operation.
Returns an ui.Image asynchronously.
Implementation
Future<ui.Image> croppedBitmap(
{ui.FilterQuality quality = FilterQuality.high}) async {
final pictureRecorder = ui.PictureRecorder();
Canvas(pictureRecorder).drawImageRect(
_bitmap,
cropSize,
Offset.zero & cropSize.size,
Paint()..filterQuality = quality,
);
//FIXME Picture.toImage() crashes on Flutter Web with the HTML renderer. Use CanvasKit or avoid this operation for now. https://github.com/flutter/engine/pull/20750
return await pictureRecorder
.endRecording()
.toImage(cropSize.width.round(), cropSize.height.round());
}