Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda