wrapped method

Implementation

AnalysisImageWrapper wrapped() {
  return AnalysisImageWrapper(
    height: height,
    width: width,
    format: AnalysisImageFormat.values.byName(format.name),
    bytes: when<Uint8List?>(
      nv21: (image) => image.bytes,
      bgra8888: (image) => image.bytes,
      jpeg: (image) => image.bytes,
      yuv420: (image) => null,
    ),
    planes: when<List<PlaneWrapper>?>(
      nv21: (image) => image.planes.map((e) => e.wrapped()).toList(),
      bgra8888: (image) => image.planes.map((e) => e.wrapped()).toList(),
      jpeg: (image) => null,
      yuv420: (image) => image.planes.map((e) => e.wrapped()).toList(),
    ),
    cropRect: when<CropRectWrapper?>(
      nv21: (image) => CropRectWrapper(
        left: image.cropRect.left.toInt(),
        top: image.cropRect.top.toInt(),
        width: image.cropRect.width.toInt(),
        height: image.cropRect.height.toInt(),
      ),
      bgra8888: (image) => null,
      jpeg: (image) => null,
      yuv420: (image) => CropRectWrapper(
        left: image.cropRect.left.toInt(),
        top: image.cropRect.top.toInt(),
        width: image.cropRect.width.toInt(),
        height: image.cropRect.height.toInt(),
      ),
    ),
    rotation: AnalysisRotation.values.byName(rotation.name),
  );
}