Showing
4 changed files
with
24 additions
and
0 deletions
| @@ -12,6 +12,7 @@ Breaking changes: | @@ -12,6 +12,7 @@ Breaking changes: | ||
| 12 | * The `autoResume` attribute has been removed from the `MobileScanner` widget. | 12 | * The `autoResume` attribute has been removed from the `MobileScanner` widget. |
| 13 | The controller already automatically resumes, so it had no effect. | 13 | The controller already automatically resumes, so it had no effect. |
| 14 | * Removed `MobileScannerCallback` and `MobileScannerArgumentsCallback` typedef. | 14 | * Removed `MobileScannerCallback` and `MobileScannerArgumentsCallback` typedef. |
| 15 | +* [Web] Replaced `jsqr` library with `zxing-js` for full barcode support. | ||
| 15 | 16 | ||
| 16 | Improvements: | 17 | Improvements: |
| 17 | * Toggling the device torch now does nothing if the device has no torch, rather than throwing an error. | 18 | * Toggling the device torch now does nothing if the device has no torch, rather than throwing an error. |
| @@ -21,6 +22,9 @@ Features: | @@ -21,6 +22,9 @@ Features: | ||
| 21 | * Added a new `placeholderBuilder` function to the `MobileScanner` widget to customize the preview placeholder. | 22 | * Added a new `placeholderBuilder` function to the `MobileScanner` widget to customize the preview placeholder. |
| 22 | * Added `autoStart` parameter to MobileScannerController(). If set to false, controller won't start automatically. | 23 | * Added `autoStart` parameter to MobileScannerController(). If set to false, controller won't start automatically. |
| 23 | * Added `hasTorch` function on MobileScannerController(). After starting the controller, you can check if the device has a torch. | 24 | * Added `hasTorch` function on MobileScannerController(). After starting the controller, you can check if the device has a torch. |
| 25 | +* [Web] Added ability to use custom barcode scanning js libraries | ||
| 26 | + by extending `WebBarcodeReaderBase` class and changing `barCodeReader` property in `MobileScannerWebPlugin` | ||
| 27 | + | ||
| 24 | 28 | ||
| 25 | Fixes: | 29 | Fixes: |
| 26 | * Fixes the missing gradle setup for the Android project, which prevented gradle sync from working. | 30 | * Fixes the missing gradle setup for the Android project, which prevented gradle sync from working. |
| @@ -35,6 +35,17 @@ class MobileScannerWebPlugin { | @@ -35,6 +35,17 @@ class MobileScannerWebPlugin { | ||
| 35 | 35 | ||
| 36 | static final html.DivElement vidDiv = html.DivElement(); | 36 | static final html.DivElement vidDiv = html.DivElement(); |
| 37 | 37 | ||
| 38 | + /// Represents barcode reader library. | ||
| 39 | + /// Change this property if you want to use a custom implementation. | ||
| 40 | + /// | ||
| 41 | + /// Example of using the jsQR library: | ||
| 42 | + /// void main() { | ||
| 43 | + /// if (kIsWeb) { | ||
| 44 | + /// MobileScannerWebPlugin.barCodeReader = | ||
| 45 | + /// JsQrCodeReader(videoContainer: MobileScannerWebPlugin.vidDiv); | ||
| 46 | + /// } | ||
| 47 | + /// runApp(const MaterialApp(home: MyHome())); | ||
| 48 | + /// } | ||
| 38 | static WebBarcodeReaderBase barCodeReader = | 49 | static WebBarcodeReaderBase barCodeReader = |
| 39 | ZXingBarcodeReader(videoContainer: vidDiv); | 50 | ZXingBarcodeReader(videoContainer: vidDiv); |
| 40 | StreamSubscription? _barCodeStreamSubscription; | 51 | StreamSubscription? _barCodeStreamSubscription; |
| @@ -20,6 +20,11 @@ class Code { | @@ -20,6 +20,11 @@ class Code { | ||
| 20 | external Uint8ClampedList get binaryData; | 20 | external Uint8ClampedList get binaryData; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | +/// Barcode reader that uses jsQR library. | ||
| 24 | +/// jsQR supports only QR codes format. | ||
| 25 | +/// | ||
| 26 | +/// Include jsQR to your index.html file: | ||
| 27 | +/// <script src="https://cdn.jsdelivr.net/npm/jsqr@1.4.0/dist/jsQR.min.js"></script> | ||
| 23 | class JsQrCodeReader extends WebBarcodeReaderBase | 28 | class JsQrCodeReader extends WebBarcodeReaderBase |
| 24 | with InternalStreamCreation, InternalTorchDetection { | 29 | with InternalStreamCreation, InternalTorchDetection { |
| 25 | JsQrCodeReader({required super.videoContainer}); | 30 | JsQrCodeReader({required super.videoContainer}); |
| @@ -134,6 +134,10 @@ extension JsZXingBrowserMultiFormatReaderExt | @@ -134,6 +134,10 @@ extension JsZXingBrowserMultiFormatReaderExt | ||
| 134 | external MediaStream? stream; | 134 | external MediaStream? stream; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | +/// Barcode reader that uses zxing-js library. | ||
| 138 | +/// | ||
| 139 | +/// Include zxing-js to your index.html file: | ||
| 140 | +/// <script type="text/javascript" src="https://unpkg.com/@zxing/library@0.19.1"></script> | ||
| 137 | class ZXingBarcodeReader extends WebBarcodeReaderBase | 141 | class ZXingBarcodeReader extends WebBarcodeReaderBase |
| 138 | with InternalStreamCreation, InternalTorchDetection { | 142 | with InternalStreamCreation, InternalTorchDetection { |
| 139 | late final JsZXingBrowserMultiFormatReader _reader = | 143 | late final JsZXingBrowserMultiFormatReader _reader = |
-
Please register or login to post a comment