decodePdf method

  1. @override
Future<List<PdfBarcode>> decodePdf({
  1. String? filePath,
  2. Uint8List? pdfBytes,
  3. required DecoderConfig config,
})
override

Platform interface method to decode barcodes from either filePath or pdfBytes.

Implementation

@override
Future<List<PdfBarcode>> decodePdf({
  String? filePath,
  Uint8List? pdfBytes,
  required DecoderConfig config,
}) async {
  try {
    final List<dynamic>? results = await methodChannel
        .invokeListMethod<dynamic>('decodePdf', {
          'filePath': filePath,
          'pdfBytes': pdfBytes,
          'config': config.toMap(),
        });

    if (results == null) return [];

    return results
        .map((e) => PdfBarcode.fromMap(e as Map<Object?, Object?>))
        .toList();
  } on PlatformException catch (e) {
    throw PdfBarcodeException(
      code: e.code,
      message: e.message ?? 'Unknown error',
      details: e.details,
    );
  }
}