scanDocument method
Launches the native document scanner and returns a single PDF file result.
Utilizes ML Kit for edge detection and automatic perspective correction. Returns null if the user cancels the operation.
Implementation
Future<AttachmentResult?> scanDocument() async {
try {
final result = await _channel.invokeMethod('scanDocument');
if (result != null && result is List) {
final images = List<String>.from(result);
if (images.isNotEmpty) {
final pdfFile = await buildPdf(images);
return _resultFromPath(pdfFile.path);
}
}
return null;
} catch (e) {
debugPrint('PixelToPdfService: scanDocument error: $e');
return null;
}
}