js_bindings 0.0.4+1 js_bindings: ^0.0.4+1 copied to clipboard
Complete JS bindings interop with autocomplete and documentation.
This is (or should be) a full JavaScript interop package using package:js bindings.
The bindings are generated by machine-reading WebIDL files for types and MDN website for documentation.
Take a look at MediaStream file and check out how nice it got with the awesome MDN documentation.
Usage #
import 'package:js_bindings/js_bindings.dart';
void main() {
var div = document.createElement('div')
..innerHTML = 'Hello world =]';
document.body!.appendChild(div);
}
Check the example tab for a more complete example.
Promise and Future #
JS Promises and Dart Futures are not the same thing.
But this package make them the same! :D
import 'package:js_bindings/js_bindings.dart';
Future<void> main() async {
// you can await like regular future
await window.navigator.mediaDevices.getUserMedia();
// or
window.navigator.mediaDevices.getUserMedia().then((event) {});
}
For a better JS interop #
If you wish for a better JS interop in Dart, please, thumbs up the following issues:
Better JS interop in general
Make awaiting a Promise as easy as a Future
Be able to use rename instance members
Donation #
Buy me a coffee or a book if you wish =]