How do I write a Dart web app that uses spawnUri and works with both Dartium and dart2js?

StackOverflow https://stackoverflow.com/questions/21226053

  •  30-09-2022
  •  | 
  •  

Question

I want to write a concurrent web app (using either raw Workers or isolates as workers). The Dart API for isolates is spawnUri, which takes a URI that points to a script.

In Dartium, that script is a .dart file. In Chrome/Firefox/etc that script is a .dart.js file.

I need to detect what runtime I'm in so I can configure the URI for spawnUri correctly. What is the best way to do this?

Était-ce utile?

La solution

SpawnUri automatically appends ".js" when compiled to JavaScript.

Autres conseils

How about using transformers? Here is a document about how transformers work, some Google internal documentation. There's also some info about transformers on pub pages - assets and transformers. What you could do is use transformers to output "rewrite" your files a bit to use correct url.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top