Using the dart:js library without a html file

Issue

Is it possible to use the dart:js library without having a html file to load the js files but some alternative way of loading the javascripts in the context?

I need this for a command-line app, so having a html file makes no sense

Solution

When you run a command line app in the DartVM there is no Javascript VM, so you cannot use Javascript libraries.

However depending on your use case, you could run your javascript code with node.js, and communicate with the DartVM using sockets.

Perhaps add some more details about your specific use case.

Update:

To run lessc from Dart, first install node.js.

Then Install lessc:

npm install -g less
lessc styles.less styles.css

You can then call lessc from Dart using dart:io Process.run().

Answered By – Greg Lowe

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.