createPage static method
Creates a page from an image file URI. The given image will be used as ORIGINAL image.
Use the shouldDetectDocument
flag to specify whether the auto-document detection
should be performed and the (cropped) DOCUMENT image should be created.
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> createPage(
Uri originalImageFileUri, bool shouldDetectDocument,
{Size? originalImageSizeLimit, Size? documentImageSizeLimit}) async {
try {
var arguments = {
'originalImageFileUri': originalImageFileUri.toString(),
'shouldDetectDocument': shouldDetectDocument
};
originalImageSizeLimit
?.let((self) => arguments["originalImageSizeLimit"] = self.toJson());
documentImageSizeLimit
?.let((self) => arguments["documentImageSizeLimit"] = self.toJson());
final pageJson = await _channel.invokeMethod('createPage', arguments);
var decoded = jsonDecode(pageJson);
return Page.fromJson(decoded);
} catch (e) {
Logger.root.severe(e);
rethrow;
}
}