flutter_js icon indicating copy to clipboard operation
flutter_js copied to clipboard

How to import INTL or other dependencies?

Open Naografix opened this issue 11 months ago • 1 comments

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

Naografix avatar Mar 19 '24 15:03 Naografix

  • I think it's because quickjs has not implement Intl.
  • you should evaluate or load module about Intl,
    • or modify quickjs c lib(difficulty)

liruohrh avatar Jul 11 '24 15:07 liruohrh