web
1.1.2, released 4 weeks ago by dart.dev
Lightweight bindings for browser APIs via JS interop
WASM-readyRock solid
What it does
Provides Dart wrappers around standard web APIs such as document, XMLHttpRequest, WebAssembly, and more. It replaces dart:html for Dart compiled to JS or WASM.
AI-written summary of version 1.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Migrating a Dart web app from dart:html to a more modern API
- Need direct access to browser APIs in a Dart-only codebase
- Want zero‑overhead bindings for web features
Skip it when
- You only need a subset of APIs and prefer a smaller dependency
- You are targeting non‑web platforms
Strengths
- Zero‑overhead, type‑safe bindings
- Supports both JS and WASM targets
- Actively maintained with migration guides
- No build_runner or code generation required
Weaknesses
- Only works on web platforms
- No support for native mobile or desktop APIs
- Requires Dart 3.13+
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Add dependency to pubspec and import 'package:web/web.dart';
import 'package:web/web.dart';
void main() {
final div = document.querySelector('div')!;
div.text = 'Text set at ${DateTime.now()}';
}Alternatives
Packages that do the same job and could replace web.
Works with
Packages commonly used together with web: ones it builds on, ones built on it, and its own family.
- httpBuilt on webA composable, Future‑based library for making HTTP requests across platforms.
- web_socket_channelBuilt on webCross‑platform WebSocket channel wrapper for Dart
- web_socketBuilt on webAn easy-to-use library for communicating with WebSockets that has multiple implementations.
- webdriverBuilt on webProvides WebDriver bindings for Dart to interact with a WebDriver remote server.
- sseBuilt on webBidirectional Server Sent Events client and server for Dart.
- package_info_plusBuilt on webFlutter plugin to query app package info like version, build number and installer store.
- firebase_core_webBuilt on webWeb implementation of firebase_core for Flutter apps.
- image_picker_for_webBuilt on webWeb implementation of image_picker that lets users select images or videos via the browser file picker.