Navaron Bracke

use the HTMLScriptElement constructor

@@ -62,20 +62,19 @@ abstract class BarcodeReader { @@ -62,20 +62,19 @@ abstract class BarcodeReader {
62 62
63 final Completer<void> completer = Completer(); 63 final Completer<void> completer = Completer();
64 64
65 - final HTMLScriptElement script =  
66 - (document.createElement('script') as HTMLScriptElement)  
67 - ..id = scriptId  
68 - ..async = true  
69 - ..defer = false  
70 - ..type = 'application/javascript'  
71 - ..lang = 'javascript'  
72 - ..crossOrigin = 'anonymous'  
73 - ..src = alternateScriptUrl ?? scriptUrl  
74 - ..onload = (JSAny _) {  
75 - if (!completer.isCompleted) {  
76 - completer.complete();  
77 - }  
78 - }.toJS; 65 + final HTMLScriptElement script = HTMLScriptElement()
  66 + ..id = scriptId
  67 + ..async = true
  68 + ..defer = false
  69 + ..type = 'application/javascript'
  70 + ..lang = 'javascript'
  71 + ..crossOrigin = 'anonymous'
  72 + ..src = alternateScriptUrl ?? scriptUrl
  73 + ..onload = (JSAny _) {
  74 + if (!completer.isCompleted) {
  75 + completer.complete();
  76 + }
  77 + }.toJS;
79 78
80 script.onerror = (JSAny _) { 79 script.onerror = (JSAny _) {
81 if (!completer.isCompleted) { 80 if (!completer.isCompleted) {