createPageWithImageBytes static method

Future<Page> createPageWithImageBytes(
  1. Uint8List imageBytes,
  2. bool shouldDetectDocument, {
  3. Size? originalImageSizeLimit,
  4. Size? documentImageSizeLimit,
})

Creates a page from image bytes. The given image will be used as ORIGINAL image. Use the shouldDetectDocument flag to specify whether the auto-document detection originalImageSizeLimit the maximum size of the original image to be saved. If the original image is larger than the specified size it will be downscaled. By default not specified. documentImageSizeLimit the maximum size of the cropped document image to be saved. If the image is larger than the specified size it will be downscaled. If originalImageSizeLimit is set it also limits the size of the cropped document image. By default not specified. return Page

Implementation

static Future<Page> createPageWithImageBytes(
  Uint8List imageBytes,
  bool shouldDetectDocument, {
  Size? originalImageSizeLimit,
  Size? documentImageSizeLimit,
}) async {
  try {
    var arguments = {
      'originalImageBytes': imageBytes,
      'shouldDetectDocument': shouldDetectDocument
    };
    originalImageSizeLimit
        ?.let((self) => arguments["originalImageSizeLimit"] = self.toJson());
    documentImageSizeLimit
        ?.let((self) => arguments["documentImageSizeLimit"] = self.toJson());
    final pageJson =
        await _channel.invokeMethod('createPageWithImageBytes', arguments);
    var decoded = jsonDecode(pageJson);
    return Page.fromJson(decoded);
  } catch (e) {
    Logger.root.severe(e);
    rethrow;
  }
}