Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
dart:js convert JsArray from allowInterop to Uint8List

I try to make my dart code to be available in JS as well. It works fine. All my code is accessible through JavaScript. The only problem I have is that allowInterop only passes dynamic types. A passed JsArray is actually a JsArray<dynamic>.

What I want to have is a Uint8List.

What I tried so far:

js.allowInterop((js.JsArray listOfInt) {
    var convertedList = Uint8List.fromList([for (var i = 0; i < listOfInt.length; i++) listOfInt[i] as int]);
    // throws: Uncaught full width integer not supported on this platform
    // if I don't cast or use int.parse(). I obviously get a type error
});

when omitting type checks and doing something like this:

js.allowInterop((js.JsArray listOfInt) {
    var convertedList = Uint8List.fromList(listOfInt);
    // throws: Uncaught full width integer not supported on this platform
});
js.allowInterop((js.JsArray listOfInt) {
    print(base64Encode(listOfInt)); // this works
    var convertedList = base64Decode(base64Encode(listOfInt));
    // throws: Uncaught full width integer not supported on this platform
});

Seems like I just don't do it right. Is it somehow possible to have less generic types passed to allowInterop or somehow ignore types in the js environment?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!