Showing
1 changed file
with
6 additions
and
8 deletions
| @@ -12,8 +12,6 @@ import 'package:mobile_scanner/src/web/zxing/result.dart'; | @@ -12,8 +12,6 @@ import 'package:mobile_scanner/src/web/zxing/result.dart'; | ||
| 12 | import 'package:mobile_scanner/src/web/zxing/zxing_browser_multi_format_reader.dart'; | 12 | import 'package:mobile_scanner/src/web/zxing/zxing_browser_multi_format_reader.dart'; |
| 13 | import 'package:web/web.dart' as web; | 13 | import 'package:web/web.dart' as web; |
| 14 | 14 | ||
| 15 | -// TODO: remove the JSAny casts once upgraded to a package:web version that restores "implements JSAny" | ||
| 16 | - | ||
| 17 | /// A barcode reader implementation that uses the ZXing library. | 15 | /// A barcode reader implementation that uses the ZXing library. |
| 18 | final class ZXingBarcodeReader extends BarcodeReader { | 16 | final class ZXingBarcodeReader extends BarcodeReader { |
| 19 | ZXingBarcodeReader(); | 17 | ZXingBarcodeReader(); |
| @@ -77,7 +75,7 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -77,7 +75,7 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 77 | web.MediaStream videoStream, | 75 | web.MediaStream videoStream, |
| 78 | ) async { | 76 | ) async { |
| 79 | final JSPromise? result = _reader?.attachStreamToVideo.callAsFunction( | 77 | final JSPromise? result = _reader?.attachStreamToVideo.callAsFunction( |
| 80 | - _reader as JSAny?, | 78 | + _reader, |
| 81 | videoStream, | 79 | videoStream, |
| 82 | videoElement, | 80 | videoElement, |
| 83 | ) as JSPromise?; | 81 | ) as JSPromise?; |
| @@ -98,7 +96,7 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -98,7 +96,7 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 98 | 96 | ||
| 99 | controller.onListen = () { | 97 | controller.onListen = () { |
| 100 | _reader?.decodeContinuously.callAsFunction( | 98 | _reader?.decodeContinuously.callAsFunction( |
| 101 | - _reader as JSAny?, | 99 | + _reader, |
| 102 | _reader?.videoElement, | 100 | _reader?.videoElement, |
| 103 | (Result? result, JSAny? error) { | 101 | (Result? result, JSAny? error) { |
| 104 | if (controller.isClosed || result == null) { | 102 | if (controller.isClosed || result == null) { |
| @@ -118,8 +116,8 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -118,8 +116,8 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 118 | // when the stream subscription returned by this method is cancelled in `MobileScannerWeb.stop()`. | 116 | // when the stream subscription returned by this method is cancelled in `MobileScannerWeb.stop()`. |
| 119 | // This avoids both leaving the barcode scanner running and a memory leak for the stream subscription. | 117 | // This avoids both leaving the barcode scanner running and a memory leak for the stream subscription. |
| 120 | controller.onCancel = () async { | 118 | controller.onCancel = () async { |
| 121 | - _reader?.stopContinuousDecode.callAsFunction(_reader as JSAny?); | ||
| 122 | - _reader?.reset.callAsFunction(_reader as JSAny?); | 119 | + _reader?.stopContinuousDecode.callAsFunction(_reader); |
| 120 | + _reader?.reset.callAsFunction(_reader); | ||
| 123 | await controller.close(); | 121 | await controller.close(); |
| 124 | }; | 122 | }; |
| 125 | 123 | ||
| @@ -157,8 +155,8 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -157,8 +155,8 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 157 | @override | 155 | @override |
| 158 | Future<void> stop() async { | 156 | Future<void> stop() async { |
| 159 | _onMediaTrackSettingsChanged = null; | 157 | _onMediaTrackSettingsChanged = null; |
| 160 | - _reader?.stopContinuousDecode.callAsFunction(_reader as JSAny?); | ||
| 161 | - _reader?.reset.callAsFunction(_reader as JSAny?); | 158 | + _reader?.stopContinuousDecode.callAsFunction(_reader); |
| 159 | + _reader?.reset.callAsFunction(_reader); | ||
| 162 | _reader = null; | 160 | _reader = null; |
| 163 | } | 161 | } |
| 164 | } | 162 | } |
-
Please register or login to post a comment