How to call a jQuery function from Dart?

Issue

This is a typical situation in jQuery:

$(".myClass").myFunction({
    aKey: 'some value'
});

How do you call that using dart:js?

The documentation is a bit cryptic and a similar question that I found here seems dated.

Solution

You can do :

main() {
  js.context.callMethod(r'$', ['.myClass'])
      .callMethod('myFunction', [new js.JsObject.jsify({'aKey': 'some value'})]);
}

Answered By – Alexandre Ardhuin

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *