js_wrapping 0.0.1-dev copy "js_wrapping: ^0.0.1-dev" to clipboard
js_wrapping: ^0.0.1-dev copied to clipboard

outdatedDart 1 only

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

6
likes
0
points
149k
downloads

Publisher

unverified uploader

Weekly Downloads

With that package you will be able to easilly wrap JS library in Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer_experimental, meta, path

More

Packages that depend on js_wrapping