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 different things.
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) {});
}

Enums

Enums like document.visibilityState are Strings in JS world, but here we work with enums instead. For example document.visibilityState is of type VisibilityState, which is a Enum.
So all of what is specificied in the W3C IDL files as enums are in fact enums in this package.

Variadic args

Dart doesn't have the concept of variadic args as JS, so we can't make a one to one there. However, we made it that variadic arguments are multiplied to 3 optional args of same type.
Example: window.console.log(1, 2, 3) - In this case all arguments are dynamic.

Todo:

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

Donation

What about a coffee?

Donate

Libraries

accelerometer
Accelerometer
all_bindings
ambient_light
Ambient Light Sensor
anchors
WebXR Anchors Module
angle_instanced_arrays
WebGL ANGLE_instanced_arrays Khronos Ratified Extension Specification
app_history
App History API
audio_output
Audio Output Devices API
autoplay
Autoplay Policy Detection
background_fetch
Background Fetch
background_sync
Web Background Synchronization
badging
Badging API
battery_status
Battery Status API
beacon
Beacon
callbacks
clipboard_apis
Clipboard API and events
close_watcher
Close Watcher API
compat
Compatibility Standard
compression
Compression Streams
compute_pressure
Compute Pressure API
console
Console Standard
contact_api
Contact Picker API
content_index
Content Index
conversion_measurement_api
Attribution Reporting
Cookie Store API
crash_reporting
Crash Reporting
credential_management_1
Credential Management Level 1
csp3
Content Security Policy Level 3
csp_embedded_enforcement
Content Security Policy: Embedded Enforcement
csp_next
Scripting Policy
css_animation_worklet_1
CSS Animation Worklet API
css_animations_1
CSS Animations Level 1
css_animations_2
CSS Animations Level 2
css_cascade_5
CSS Cascading and Inheritance Level 5
css_conditional_3
CSS Conditional Rules Module Level 3
css_counter_styles_3
CSS Counter Styles Level 3
css_device_adapt_1
CSS Device Adaptation Module Level 1
css_font_loading_3
CSS Font Loading Module Level 3
css_fonts_4
CSS Fonts Module Level 4
css_highlight_api_1
CSS Custom Highlight API Module Level 1
css_images_4
CSS Images Module Level 4
css_layout_api_1
CSS Layout API Level 1
css_masking_1
CSS Masking Module Level 1
css_nav_1
CSS Spatial Navigation Level 1
css_nesting_1
CSS Nesting Module
css_paint_api_1
CSS Painting API Level 1
css_parser_api
CSS Parser API
css_properties_values_api_1
CSS Properties and Values API Level 1
css_pseudo_4
CSS Pseudo-Elements Module Level 4
css_regions_1
CSS Regions Module Level 1
css_shadow_parts_1
CSS Shadow Parts
css_transitions_1
CSS Transitions
css_transitions_2
CSS Transitions Level 2
css_typed_om_1
CSS Typed OM Level 1
cssom_1
CSS Object Model (CSSOM)
cssom_view_1
CSSOM View Module
custom_state_pseudo_class
Custom State Pseudo Class
datacue
DataCue API
deprecation_reporting
Deprecation Reporting
device_memory_1
Device Memory 1
device_posture
Device Posture API
document
dom
DOM Standard
dom_parsing
DOM Parsing and Serialization
edit_context
EditContext API
element_timing
Element Timing API
encoding
Encoding Standard
encrypted_media
Encrypted Media Extensions
entries_api
File and Directory Entries API
event_timing
Event Timing API
ext_blend_minmax
WebGL EXT_blend_minmax Khronos Ratified Extension Specification
ext_clip_cull_distance
WebGL EXT_clip_cull_distance Extension Draft Specification
ext_color_buffer_float
WebGL EXT_color_buffer_float Extension Specification
ext_color_buffer_half_float
WebGL EXT_color_buffer_half_float Extension Specification
ext_disjoint_timer_query
WebGL EXT_disjoint_timer_query Extension Specification
ext_disjoint_timer_query_webgl2
WebGL EXT_disjoint_timer_query_webgl2 Extension Specification
ext_float_blend
WebGL EXT_float_blend Extension Specification
ext_frag_depth
WebGL EXT_frag_depth Khronos Ratified Extension Specification
ext_shader_texture_lod
WebGL EXT_shader_texture_lod Khronos Ratified Extension Specification
ext_srgb
WebGL EXT_sRGB Extension Specification
ext_texture_compression_bptc
WebGL EXT_texture_compression_bptc Extension Specification
ext_texture_compression_rgtc
WebGL EXT_texture_compression_rgtc Extension Specification
ext_texture_filter_anisotropic
WebGL EXT_texture_filter_anisotropic Khronos Ratified Extension Specification
ext_texture_norm16
WebGL EXT_texture_norm16 Extension Specification
eyedropper_api
EyeDropper API
fetch
Fetch Standard
file_system_access
File System Access
fileapi
File API
filter_effects_1
Filter Effects Module Level 1
floc
Federated Learning of Cohorts
font_metrics_api_1
Font Metrics API Level 1
fullscreen
Fullscreen API Standard
gamepad
Gamepad
gamepad_extensions
Gamepad Extensions
generic_sensor
Generic Sensor API
geolocation
Geolocation API
geolocation_sensor
Geolocation Sensor
geometry_1
Geometry Interfaces Module Level 1
Get Installed Related Apps API
gyroscope
Gyroscope
hr_time_3
High Resolution Time
html
HTML Standard
html_media_capture
HTML Media Capture
idle_detection
Idle Detection API
image_capture
MediaStream Image Capture
image_resource
Image Resource
indexeddb_3
Indexed Database API 3.0
ink_enhancement
Ink API
input_device_capabilities
Input Device Capabilities
input_events_2
Input Events Level 2
intersection_observer
Intersection Observer
intervention_reporting
Intervention Reporting
is_input_pending
Early detection of input events
js_bindings
js_self_profiling
JS Self-Profiling API
keyboard_lock
Keyboard Lock
keyboard_map
Keyboard Map
khr_parallel_shader_compile
WebGL KHR_parallel_shader_compile Extension Specification
largest_contentful_paint
Largest Contentful Paint
layout_instability
Layout Instability API
local_font_access
Local Font Access API
longtasks_1
Long Tasks API
magnetometer
Magnetometer
manifest_incubations
Manifest Incubations
mathml_core
MathML Core
media_capabilities
Media Capabilities
media_playback_quality
Media Playback Quality
media_source_2
Media Source Extensions™
mediacapture_automation
Media Capture Automation
mediacapture_fromelement
Media Capture from DOM Elements
mediacapture_region
Region Capture
mediacapture_streams
Media Capture and Streams
mediacapture_transform
MediaStreamTrack Insertable Media Processing using Streams
mediasession
Media Session Standard
mediastream_recording
MediaStream Recording
mst_content_hint
MediaStreamTrack Content Hints
Navigation Timing Level 2
netinfo
Network Information API
notifications
Notifications API Standard
oes_draw_buffers_indexed
WebGL OES_draw_buffers_indexed Extension Specification
oes_element_index_uint
WebGL OES_element_index_uint Khronos Ratified Extension Specification
oes_fbo_render_mipmap
WebGL OES_fbo_render_mipmap Extension Specification
oes_standard_derivatives
WebGL OES_standard_derivatives Khronos Ratified Extension Specification
oes_texture_float
WebGL OES_texture_float Khronos Ratified Extension Specification
oes_texture_float_linear
WebGL OES_texture_float_linear Khronos Ratified Extension Specification
oes_texture_half_float
WebGL OES_texture_half_float Khronos Ratified Extension Specification
oes_texture_half_float_linear
WebGL OES_texture_half_float_linear Khronos Ratified Extension Specification
oes_vertex_array_object
WebGL OES_vertex_array_object Khronos Ratified Extension Specification
orientation_event
DeviceOrientation Event Specification
orientation_sensor
Orientation Sensor
origin_policy
Origin Policy
ovr_multiview2
WebGL OVR_multiview2 Extension Specification
page_lifecycle
Page Lifecycle
paint_timing
Paint Timing 1
payment_handler
Payment Handler API
payment_request
Payment Request API
performance_measure_memory
Measure Memory API
performance_timeline
Performance Timeline Level 2
periodic_background_sync
Web Periodic Background Synchronization
permissions
Permissions
permissions_policy_1
Permissions Policy
permissions_request
Requesting Permissions
permissions_revoke
Relinquishing Permissions
picture_in_picture
Picture-in-Picture
pointerevents3
Pointer Events
pointerlock_2
Pointer Lock 2.0
portals
Portals
prefer_current_tab
preferCurrentTab
presentation_api
Presentation API
priority_hints
Priority Hints
private_click_measurement
Private Click Measurement
proximity
Proximity Sensor
push_api
Push API
referrer_policy
Referrer Policy
remote_playback
Remote Playback API
reporting_1
Reporting API 1
requestidlecallback
Cooperative Scheduling of Background Tasks
resize_observer_1
Resize Observer
resource_timing_2
Resource Timing Level 2
sanitizer_api
HTML Sanitizer API
savedata
Save Data API
scheduling_apis
Prioritized Task Scheduling
screen_capture
Screen Capture
screen_orientation
The Screen Orientation API
screen_wake_lock
Screen Wake Lock API
scroll_animations_1
Scroll-linked Animations
scroll_to_text_fragment
Text Fragments
secure_payment_confirmation
Secure Payment Confirmation
selection_api
Selection API
serial
Web Serial API
server_timing
Server Timing
service_workers_1
Service Workers Nightly
shape_detection_api
Accelerated Shape Detection in Images
speech_api
Web Speech API
storage
Storage Standard
storage_access
The Storage Access API
streams
Streams Standard
svg2
Scalable Vector Graphics (SVG) 2
svg_animations
SVG Animations
testutils
Test Utils Standard
text_detection_api
Accelerated Text Detection in Images
touch_events
Touch Events - Level 2
trusted_types
Trusted Types
ua_client_hints
User-Agent Client Hints
uievents
UI Events
url
URL Standard
urlpattern
URLPattern API
user_timing
User Timing Level 3
vibration
Vibration API (Second Edition)
video_rvfc
HTMLVideoElement.requestVideoFrameCallback()
virtual_keyboard
VirtualKeyboard API
visual_viewport
Visual Viewport API
wai_aria_1_2
Accessible Rich Internet Applications (WAI-ARIA) 1.3
wasm_js_api_1
WebAssembly JavaScript Interface
wasm_web_api_1
WebAssembly Web API
web_animations_1
Web Animations
web_animations_2
Web Animations Level 2
web_bluetooth
Web Bluetooth
web_locks
Web Locks API
web_nfc
Web NFC
web_otp
WebOTP API
web_share
Web Share API
webaudio
Web Audio API
webauthn_3
Web Authentication: An API for accessing Public Key Credentials - Level
webcodecs
WebCodecs
webcryptoapi
Web Cryptography API
webdriver2
WebDriver
webgl1
WebGL Specification
webgl2
WebGL 2.0 Specification
webgl_blend_equation_advanced_coherent
WebGL WEBGL_blend_equation_advanced_coherent Extension Draft Specification
webgl_color_buffer_float
WebGL WEBGL_color_buffer_float Extension Specification
webgl_compressed_texture_astc
WebGL WEBGL_compressed_texture_astc Extension Specification
webgl_compressed_texture_etc
WebGL WEBGL_compressed_texture_etc Extension Specification
webgl_compressed_texture_etc1
WebGL WEBGL_compressed_texture_etc1 Extension Specification
webgl_compressed_texture_pvrtc
WebGL WEBGL_compressed_texture_pvrtc Extension Specification
webgl_compressed_texture_s3tc
WebGL WEBGL_compressed_texture_s3tc Khronos Ratified Extension Specification
webgl_compressed_texture_s3tc_srgb
WebGL WEBGL_compressed_texture_s3tc_srgb Extension Specification
webgl_debug_renderer_info
WebGL WEBGL_debug_renderer_info Khronos Ratified Extension Specification
webgl_debug_shaders
WebGL WEBGL_debug_shaders Khronos Ratified Extension Specification
webgl_depth_texture
WebGL WEBGL_depth_texture Khronos Ratified Extension Specification
webgl_draw_buffers
WebGL WEBGL_draw_buffers Khronos Ratified Extension Specification
webgl_draw_instanced_base_vertex_base_instance
WebGL WEBGL_draw_instanced_base_vertex_base_instance Extension Draft Specification
webgl_lose_context
WebGL WEBGL_lose_context Khronos Ratified Extension Specification
webgl_multi_draw
WebGL WEBGL_multi_draw Extension Specification
webgl_multi_draw_instanced_base_vertex_base_instance
WebGL WEBGL_multi_draw_instanced_base_vertex_base_instance Extension Draft Specification
webgpu
WebGPU
webhid
WebHID API
webidl
Web IDL Standard
webmidi
Web MIDI API
webnn
Web Neural Network API
webrtc
WebRTC 1.0: Real-Time Communication Between Browsers
webrtc_encoded_transform
WebRTC Encoded Transform
webrtc_ice
IceTransport Extensions for WebRTC
webrtc_identity
Identity for WebRTC 1.0
webrtc_priority
WebRTC Priority Control API
webrtc_stats
Identifiers for WebRTC's Statistics API
webrtc_svc
Scalable Video Coding (SVC) Extension for WebRTC
webtransport
WebTransport
webusb
WebUSB API
webvtt1
WebVTT: The Web Video Text Tracks Format
webxr
WebXR Device API
webxr_ar_module_1
WebXR Augmented Reality Module - Level 1
webxr_depth_sensing_1
WebXR Depth Sensing Module
webxr_dom_overlays_1
WebXR DOM Overlays Module
webxr_gamepads_module_1
WebXR Gamepads Module - Level 1
webxr_hand_input_1
WebXR Hand Input Module - Level 1
webxr_hit_test_1
WebXR Hit Test Module
webxr_lighting_estimation_1
WebXR Lighting Estimation API Level 1
webxrlayers_1
WebXR Layers API Level 1
window
window_controls_overlay
Window Controls Overlay
xhr
XMLHttpRequest Standard