js_wrapping 0.1.1 copy "js_wrapping: ^0.1.1" to clipboard
js_wrapping: ^0.1.1 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
pub points
92%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on js_wrapping