Test Dart and dart2js code in same page


I trying my luck on Dart.
I’ve got an application that loads the Dart file and the generated Javascript:

<script type="application/dart" src="/bones/build/web/quiz/quiz1.dart">
<script src="/bones/build/web/quiz/quiz1.dart.js">

When I open this page in Dartium, both the Javascript and the Dart code are run (I only need one).
How do I go about to run only the Dart file, and not the Javascript when opened in Dartium, and run the Javascript when opened in Firefox or Chromium?

Should I create two pages, one for Dart and one for Javascript?
That means I’d have to edit two files when I want to change anything. Feels wrong to me.

Kind regards,
Hendrik Jan

—- EDIT —-
I now realise that it might be important that this application is written in PHP using the Laravel framework.


I found the following solution that works for me. In stead of linking to the generated Javascript file (as I did in my question), I link to dart.js which will load the generated Javascript in case Dart is not supported in the browser, like this:

<script type="application/dart" src="/bones/build/web/quiz/quiz1.dart">
<script src="/bones/build/web/packages/browser/dart.js">

This makes it possible for me to see the result of my work in Dartium and also in Firefox and Chromium.

Answered By – Hendrik Jan

Answer Checked By – Senaida (FlutterFixes Volunteer)

Leave a Reply

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