Skip to content Skip to sidebar Skip to footer

How To Use A JS Library And A JS Function In A Flutter Mobile App?

I want to use a JavaScript library in my mobile Flutter project. Here is the link for this library on github. Library How can I use this library and a function(aboutnumber()) from

Solution 1:

You can use https://pub.dev/packages/flutter_js package. It allows to evaluate pure javascript code inside mobile and desktop flutter apps. By pure, I mean the package is not a browser engine, so no web API , localstorage or another browser api are available. But you can bundle some javascript code containing javascripts libraries like moment, ajv and maybe the one you related in your question if it relies only in javascript. The flutter_js injects into the javascript engine, things like console.log, xhr and fetch. But it is all. There is a send message channel which you could use to inject objects into the engine which you could provide objects which will be implemented and dart, but will be shared into the javascript global space.

In Flutter web, the javascript integration is possible using the package:js, mentioned in another answer.

Disclaimer: I'm the author of the flutter_js package


Solution 2:

This is not possible on any platform other than the web, as described in the JS interop documentation.

On the Web, package:js can be used.


Post a Comment for "How To Use A JS Library And A JS Function In A Flutter Mobile App?"