Committed by
GitHub
Merge pull request #519 from p-mazhnik/pavel/web-fix
fix(web): waiting for js libs to load
Showing
1 changed file
with
4 additions
and
1 deletions
| @@ -26,7 +26,7 @@ class MobileScannerWebPlugin { | @@ -26,7 +26,7 @@ class MobileScannerWebPlugin { | ||
| 26 | ); | 26 | ); |
| 27 | final MobileScannerWebPlugin instance = MobileScannerWebPlugin(); | 27 | final MobileScannerWebPlugin instance = MobileScannerWebPlugin(); |
| 28 | 28 | ||
| 29 | - injectJSLibraries(barCodeReader.jsLibraries); | 29 | + _jsLibrariesLoadingFuture = injectJSLibraries(barCodeReader.jsLibraries); |
| 30 | 30 | ||
| 31 | channel.setMethodCallHandler(instance.handleMethodCall); | 31 | channel.setMethodCallHandler(instance.handleMethodCall); |
| 32 | event.setController(instance.controller); | 32 | event.setController(instance.controller); |
| @@ -55,8 +55,11 @@ class MobileScannerWebPlugin { | @@ -55,8 +55,11 @@ class MobileScannerWebPlugin { | ||
| 55 | ZXingBarcodeReader(videoContainer: vidDiv); | 55 | ZXingBarcodeReader(videoContainer: vidDiv); |
| 56 | StreamSubscription? _barCodeStreamSubscription; | 56 | StreamSubscription? _barCodeStreamSubscription; |
| 57 | 57 | ||
| 58 | + static late Future _jsLibrariesLoadingFuture; | ||
| 59 | + | ||
| 58 | /// Handle incomming messages | 60 | /// Handle incomming messages |
| 59 | Future<dynamic> handleMethodCall(MethodCall call) async { | 61 | Future<dynamic> handleMethodCall(MethodCall call) async { |
| 62 | + await _jsLibrariesLoadingFuture; | ||
| 60 | switch (call.method) { | 63 | switch (call.method) { |
| 61 | case 'start': | 64 | case 'start': |
| 62 | return _start(call.arguments as Map); | 65 | return _start(call.arguments as Map); |
-
Please register or login to post a comment