Intento que mi código dart también esté disponible en JS. Funciona bien. Todo mi código es accesible a través de JavaScript. El único problema que tengo es que allowInterop solo pasa tipos dynamic . Un JsArray aprobado es en realidad un JsArray<dynamic> .
Lo que quiero tener es un Uint8List .
Lo que probé hasta ahora:
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 });al omitir las comprobaciones de tipo y hacer algo como esto:
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 }); Parece que simplemente no lo hago bien. ¿Es posible de alguna manera pasar tipos menos genéricos a allowInterop o ignorar de alguna manera los tipos en el entorno js?