2

I am trying to use React library from withing Dart.

However, I need to provide various functions that are called by React with this bound to some javascript object. I know, that I can provide Dart callbacks to javascript code using js interop Callback class, however I have no idea, how to access javascript this within these callbacks.

Could you please help me find out?

1 Answer 1

2

You have to use the optional named parameter withThis on Callback creation. With that, the javascript this will be added as first parameter when the dart function will be called. Something like :

var func = (jsThis, arg1) {
  // do the job with jsThis
};
new Callback.many(func, withThis: true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.