Dart – running a project does not load the dart file and not printing in the console

Issue

I have created a new project in dart and added some code, but when I run (I doesn’t matter if I run the dart file with “Run in Dartium” or if Ctrl + R) the dart file is not showing the button that I’ve create in the main, also in the main() method I’ve added a print() in order to print a message in the console, but nothing is showed.

Also: if I run with “Run as JavaScript” the button is showed normally, here is what I’m doing:

enter image description here

1.-my html code:

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Capitulo9</title>
    <link rel="stylesheet" href="capitulo9.css">
  </head>
  <body>


    <script type="application/dart" src="capitulo9.dart"></script>
    <script src="packages/browser/dart.js"></script>
    capitulo9.dart

  </body>
</html>

2.-my dart file (forget the code from above everything is commented) I want to print the the message and create the button:

main() {

  print("I wish to print this in the console");

  var startButton = new Element.html("<button>Start</button>");
    document.body.children.add(startButton);
}

3.-I have run it with “Run in Dartium” and with the green icon
4.-That’s what I get, no button
5.-no message printed
6.-also no message printed

How should I suppose to run in dart? thanks

Solution

My guess is that your copy of Dartium expired. It only works for 60 days, and then you need to upgrade it.

I recently found that it didn’t even show a message to tell you why it wasn’t working (though I believe it’s supposed to). I raised a bug about this; though there’s been no repsonse so far.

Upgrading to the latest code would’ve given you the latest Dartium and fixed it.

Answered By – Danny Tuppeny

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.