Navaron Bracke

add stub for ZXing barcode reader

  1 +import 'package:mobile_scanner/src/enums/barcode_format.dart';
  2 +import 'package:mobile_scanner/src/web/barcode_reader.dart';
  3 +import 'package:mobile_scanner/src/web/zxing/zxing_browser_multi_format_reader.dart';
  4 +
  5 +/// A barcode reader implementation that uses the ZXing library.
  6 +final class ZXingBarcodeReader extends BarcodeReader {
  7 + ZXingBarcodeReader();
  8 +
  9 + /// The internal barcode reader.
  10 + ZXingBrowserMultiFormatReader? _reader;
  11 +
  12 + @override
  13 + String get scriptUrl => 'https://unpkg.com/@zxing/library@0.19.1';
  14 +
  15 + /// Get the barcode format from the ZXing library, for the given [format].
  16 + int getZXingBarcodeFormat(BarcodeFormat format) {
  17 + switch (format) {
  18 + case BarcodeFormat.aztec:
  19 + return 0;
  20 + case BarcodeFormat.codabar:
  21 + return 1;
  22 + case BarcodeFormat.code39:
  23 + return 2;
  24 + case BarcodeFormat.code93:
  25 + return 3;
  26 + case BarcodeFormat.code128:
  27 + return 4;
  28 + case BarcodeFormat.dataMatrix:
  29 + return 5;
  30 + case BarcodeFormat.ean8:
  31 + return 6;
  32 + case BarcodeFormat.ean13:
  33 + return 7;
  34 + case BarcodeFormat.itf:
  35 + return 8;
  36 + case BarcodeFormat.pdf417:
  37 + return 10;
  38 + case BarcodeFormat.qrCode:
  39 + return 11;
  40 + case BarcodeFormat.upcA:
  41 + return 14;
  42 + case BarcodeFormat.upcE:
  43 + return 15;
  44 + case BarcodeFormat.unknown:
  45 + case BarcodeFormat.all:
  46 + return -1;
  47 + }
  48 + }
  49 +}