Skip to content
pubscout

universal_html

2.3.0, released a year ago by dint.dev

Cross‑platform replacement for dart:html with DOM parsing, XML support, and EventSource.

$ flutter pub add universal_html
Source repository

What it does

Provides a unified API for manipulating HTML and XML documents on browsers, mobile, desktop, server, and Node.js. It also offers a WindowController for HTTP requests and an EventSource implementation that works outside browsers.

AI-written summary of version 2.3.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Need to parse or manipulate HTML/XML in a non‑browser Dart environment
  • Building a web scraper or crawler that runs on server or desktop
  • Using EventSource streams in Flutter or server apps

Skip it when

  • Building a full Flutter UI that relies on real browser widgets
  • Performance‑critical DOM manipulation where native dart:html is required

Strengths

  • Cross‑platform API, no need to switch imports
  • Built‑in EventSource support with customizable headers
  • Comprehensive DOM query and manipulation methods

Weaknesses

  • No Flutter widgets, only core DOM helpers
  • Not a UI framework, so not useful for building UIs
  • Requires manual handling of HTTP client for some features

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
9

Add dependency in pubspec: universal_html: ^2.3.0

import "package:universal_html/universal_html.dart";

void main() {
  final div = DivElement();
  div.append(Element.tag("h1")..appendText("Hello world!"));
  print(div.outerHtml); // <div><h1>Hello world!</h1></div>
}

Alternatives

Packages that do the same job and could replace universal_html.

Works with

Packages commonly used together with universal_html: ones it builds on, ones built on it, and its own family.