getPictures static method
Gets pictures from the device camera.
noOfPages specifies the maximum number of pages to scan (default: 1)
isGalleryImportAllowed enables importing from gallery on Android (default: false)
useCustomScanner forces use of custom scanner UI on Android instead of ML Kit (default: false)
Note: Custom scanner respects app locale, while ML Kit uses device system language
iosScannerOptions optional iOS-specific scanner options
Returns a list of file paths to the scanned images, or null if cancelled
Implementation
static Future<List<String>?> getPictures({
int noOfPages = 1,
bool isGalleryImportAllowed = false,
bool useCustomScanner = false,
Map<String, dynamic>? iosScannerOptions,
}) async {
// Request camera permission
var status = await Permission.camera.status;
if (!status.isGranted) {
status = await Permission.camera.request();
if (!status.isGranted) {
throw PlatformException(
code: 'PERMISSION_DENIED',
message: 'Camera permission is required to scan documents',
);
}
}
try {
final List<dynamic>? pictures = await _channel.invokeMethod(
'getPictures',
{
'noOfPages': noOfPages,
'isGalleryImportAllowed': isGalleryImportAllowed,
'useCustomScanner': useCustomScanner,
if (iosScannerOptions != null) 'iosScannerOptions': iosScannerOptions,
},
);
return pictures?.cast<String>();
} on PlatformException {
rethrow;
}
}