scanFromBytes method

  1. @override
Future<List<QrScanResult>> scanFromBytes(
  1. Uint8List imageBytes,
  2. ScanOptions options
)
override

Scans QR/Barcode from image bytes

Implementation

@override
Future<List<QrScanResult>> scanFromBytes(
  Uint8List imageBytes,
  ScanOptions options,
) async {
  try {
    final results = await methodChannel.invokeMethod<List<dynamic>>(
      'scanFromBytes',
      {'imageBytes': imageBytes, ...options.toJson()},
    );

    if (results == null) return [];

    return results
        .map(
          (result) =>
              QrScanResult.fromJson(Map<String, dynamic>.from(result)),
        )
        .toList();
  } on PlatformException catch (e) {
    throw _handlePlatformException(e);
  }
}