Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

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 is 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);
}

promise and future

js promises and dart futures are not the same thing.
this package addes an easy way to use promises:

import 'package:js_bindings/js_bindings.dart';

future<void> main() async {
  await window.navigator.mediadevices.getusermedia().future;
  // or
  window.navigator.mediadevices.getusermedia().then((event) {});
}

what to import

there is a folder called bindings and there is one dart file for each idl spec.
for example orientation_event:

import 'package:js_bindings/bindings/orientation_event.dart';

future<void> main() async {
  final permission = await deviceorientationevent.requestpermission().future;

  print('granted? ${permission == permissionstate.granted}');
}

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


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.