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

Issue

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?

Solution

SpawnUri automatically appends “.js” when compiled to JavaScript.

Answered By – Florian Loitsch

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *