Dart with jQuery
There is no doubt that jQuery has become very popular among developers because of its simplicity. Let's try to combine the simplicity of jQuery and the power of Dart in a real example. For demonstration purposes, we created the js_proxy
package to help the Dart code to communicate with jQuery. It is available on the pub manager at https://pub.dartlang.org/packages/js_proxy. This package is layered on dart:js
and has a library of the same name and sole class JProxy
. An instance of the JProxy
class can be created via the generative constructor where we can specify the optional reference on the proxied JsObject
:
JProxy([this._object]);
We can create an instance of JProxy
with a named constructor and provide the name of the JavaScript object accessible through the dart:js
context as follows:
JProxy.fromContext(String name) { _object = js.context[name]; }
The JProxy
instance keeps the reference on the proxied JsObject
class and makes all the manipulation on it, as shown in the...