allowInterop function
Function allowInterop(Returns a wrapper around function f
that can be called from JavaScript using the package:js Dart-JavaScript interop.
For performance reasons in Dart2Js, by default Dart functions cannot be passed directly to JavaScript unless this method is called to create a Function compatible with both Dart and JavaScript. Calling this method repeatedly on a function will return the same function. The Function returned by this method can be used from both Dart and JavaScript. We may remove the need to call this method completely in the future if Dart2Js is refactored so that its function calling conventions are more compatible with JavaScript.
Source
Function/*=F*/ allowInterop/*<F extends Function>*/(Function/*=F*/ f) { if (f is JSFunction) { // The function is already a JSFunction... no need to do anything. return f; } else { return JSFunction._create(f); } }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-js/allowInterop.html