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?