p-mazhnik

docs(web): update changelog, add comments

... ... @@ -12,6 +12,7 @@ Breaking changes:
* The `autoResume` attribute has been removed from the `MobileScanner` widget.
The controller already automatically resumes, so it had no effect.
* Removed `MobileScannerCallback` and `MobileScannerArgumentsCallback` typedef.
* [Web] Replaced `jsqr` library with `zxing-js` for full barcode support.
Improvements:
* Toggling the device torch now does nothing if the device has no torch, rather than throwing an error.
... ... @@ -21,6 +22,9 @@ Features:
* Added a new `placeholderBuilder` function to the `MobileScanner` widget to customize the preview placeholder.
* Added `autoStart` parameter to MobileScannerController(). If set to false, controller won't start automatically.
* Added `hasTorch` function on MobileScannerController(). After starting the controller, you can check if the device has a torch.
* [Web] Added ability to use custom barcode scanning js libraries
by extending `WebBarcodeReaderBase` class and changing `barCodeReader` property in `MobileScannerWebPlugin`
Fixes:
* Fixes the missing gradle setup for the Android project, which prevented gradle sync from working.
... ...
... ... @@ -35,6 +35,17 @@ class MobileScannerWebPlugin {
static final html.DivElement vidDiv = html.DivElement();
/// Represents barcode reader library.
/// Change this property if you want to use a custom implementation.
///
/// Example of using the jsQR library:
/// void main() {
/// if (kIsWeb) {
/// MobileScannerWebPlugin.barCodeReader =
/// JsQrCodeReader(videoContainer: MobileScannerWebPlugin.vidDiv);
/// }
/// runApp(const MaterialApp(home: MyHome()));
/// }
static WebBarcodeReaderBase barCodeReader =
ZXingBarcodeReader(videoContainer: vidDiv);
StreamSubscription? _barCodeStreamSubscription;
... ...
... ... @@ -20,6 +20,11 @@ class Code {
external Uint8ClampedList get binaryData;
}
/// Barcode reader that uses jsQR library.
/// jsQR supports only QR codes format.
///
/// Include jsQR to your index.html file:
/// <script src="https://cdn.jsdelivr.net/npm/jsqr@1.4.0/dist/jsQR.min.js"></script>
class JsQrCodeReader extends WebBarcodeReaderBase
with InternalStreamCreation, InternalTorchDetection {
JsQrCodeReader({required super.videoContainer});
... ...
... ... @@ -134,6 +134,10 @@ extension JsZXingBrowserMultiFormatReaderExt
external MediaStream? stream;
}
/// Barcode reader that uses zxing-js library.
///
/// Include zxing-js to your index.html file:
/// <script type="text/javascript" src="https://unpkg.com/@zxing/library@0.19.1"></script>
class ZXingBarcodeReader extends WebBarcodeReaderBase
with InternalStreamCreation, InternalTorchDetection {
late final JsZXingBrowserMultiFormatReader _reader =
... ...