js_wrapping 0.0.1-dev js_wrapping: ^0.0.1-dev copied to clipboard
With that package you will be able to easilly wrap JS library in Dart.
Dart Js Wrapping #
This project provides some base classes to simplify the creation of Dart libraries that wraps JS libraries.
Wrappers are based on dart:js. The main class is TypedJsObject
.
Example #
Given a JS class like :
Person = function(name) {
this.name = name;
}
Person.prototype.setAge = function(age) {
this.age = age;
}
Person.prototype.getAge = function() {
return this.age;
}
You can create a wrapper like :
import 'dart:js' as js;
class Person extends TypedJsObject {
Person(String name) : super(js.context['Person', [name]]);
set name(String name) => $unsafe['name'] = name;
String get name => $unsafe['name'];
set age(int age) => $unsafe.callMethod('setAge', [age]);
int get age => $unsafe.callMethod('getAge');
}
License #
Apache 2.0