abner / flutter_js

A Javascript engine to use with flutter. It uses quickjs on Android and JavascriptCore on IOS
MIT License
473 stars 124 forks source link

How to import INTL or other dependencies? #148

Open Naografix opened 8 months ago

Naografix commented 8 months ago

Hello, i'm playing with Flutter_js and I have a little problem right now:

This is my test.js (from Mozilla Doc) :

function log(count) {
   const formattedCount = new Intl.NumberFormat(navigator.languages).format(count);
   return formattedCount;
}

My page.dart:

var myMethod = "log(26254.39);";
var flutterJs = getJavascriptRuntime();
var path = await rootBundle.loadString("lib/core/ressources/test.js");
JsEvalResult jsEvalResult = flutterJs.evaluate("$path$myMethod");
var result = jsEvalResult.stringResult;

And this is my error:

I/flutter (16439): ReferenceError: 'Intl' is not defined I/flutter (16439): at log (:3) I/flutter (16439): at (:5)

How to import INTL for my javascript process?

Thanks

liruohrh commented 4 months ago