scanFile static method

Future<String?> scanFile({
  1. required String path,
  2. List<BarcodeFormat> formats = const [],
})

If formats parameter is an empty list it will scan for all possible formats

Implementation

static Future<String?> scanFile({
  required String path,
  List<BarcodeFormat> formats = const [],
}) async {
  try {
    final listFormats = _conventFormatsToList(formats);
    Map<String, dynamic> arguments = {
      'filePath': path,
      'barcodeFormats': listFormats,
    };
    if (path.endsWith('.pdf')) {
      return _channel.invokeMethod('scan_pdf', arguments);
    }
    return _channel.invokeMethod('scan_image', arguments);
  } catch (e) {
    throw Exception();
  }
}