0

Not sure if its a compiler limitation or something I don't understand (likely the last :-))

I'm trying to access a "DataView" structure buried in an native java-script class. I got it to work in debug mode; however, when compiled for deployment, the solution isn't working.

  await _transferIn(adapter, 5, 64).then((usbInTransferResult){
    log.finest('_transferIn.then');
    js.context['console'].callMethod('log', [usbInTransferResult]);

    var rxLen = usbInTransferResult['data']['byteLength'];  <<<<< Fails
    for( var index = 0; index < rxLen; index++ ){
      rxData.add(usbInTransferResult['data'].callMethod('getUint8', [index]));  <<<<< Fails
    };

    log.finest(rxData);
    return completer.complete(rxData);
  });

The above code reads a data packet received through USB (WebUSB). It reads the received package length and puts it copies each byte into a List<int>. In both places (reading the property byteLength and calling method getUint8([index]) fails only when compiled for deployment.

Below a picture of the reported error Snapshot Error

Below a picture of a successful run (in debug mode) Please notice the additional DART symbols (which are missing in the picture above). Snapshot success

ps. I'm using DART-SDK 2.0.0 (tried also 2.1.0-dev.8.0), and Angular-DART 5.0.0, within a WebStorm project.

Bas E
  • 96
  • 1
  • 7

1 Answers1

0

See the js package and it's documentation for how to wrap a javascript API with something callable from Dart.

Nate Bosch
  • 10,145
  • 2
  • 26
  • 22
  • Hi Nate.Thanks for the feedback. As I'm struggling a bit maybe you can point a bit further. The challenge I'm facing is with a structure passed to DART through a callback (It seems js package addresses the other-way around from DART -> JS). Please also remember, the solution works in debug mode, but fails when deployed. – Bas E Nov 13 '18 at 22:48