universal_html 0.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 63

Overview #

This package is a pure Dart implemention of a subset of dart:html. The package works in all platforms (VM, Flutter, and browser).

Licensed under the MIT license.

The project welcomes new contributors:

Use cases #

  • Parsing/scraping HTML in the server/Flutter + browser.
  • Generating HTML in the server/Flutter + browser.

Features #

DOM APIs #

  • Node classes (Node, Element, CheckboxInputElement, etc.)
  • Printing (element.outerHtml, etc.)
  • Parsing (DomParser)
  • Queries (document.querySelector, node.matchesSelector)
  • Event handlers

Other APIs #

We have implemented various other APIs such as subsets ofwindow and navigator. Non-implemented APIs either throw UnimplementedError or fail silently when used in non-browser environment.

Correctness #

We test that the APIs behave identically to dart:html code running in Chrome. There are some failing tests.

For parsing, we use:

Getting started #

In pubspec.yaml:

name: example
dependencies:
  universal_html: ^0.1.0

Now you can replace usage of "dart:html" with "package:universal_html/html.dart":

import "package:universal_html/html.dart";

void main() {
  // Create a DOM tree
  final element = new Element.tag("h1")..appendText("Hello world!");

  // Print outer HTML
  print(element.outerHtml);
}

0.0.1 #

  • Initial release

example/universal_html.dart

import "package:universal_html/html.dart";

void main() {
  // Create a DOM tree
  final element = Element.tag("h1")..appendText("Hello world!");

  // Print outer HTML
  print(element.outerHtml);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  universal_html: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:universal_html/html.dart';
import 'package:universal_html/html_driver.dart';
import 'package:universal_html/svg.dart';
  
Version Uploaded Documentation Archive
0.1.0 Feb 18, 2019 Go to the documentation of universal_html 0.1.0 Download universal_html 0.1.0 archive
0.0.1 Jan 5, 2019 Go to the documentation of universal_html 0.0.1 Download universal_html 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Fix lib/src/html/event.dart. (-0.50 points)

Analysis of lib/src/html/event.dart reported 1 hint:

line 66 col 32: Use isNotEmpty instead of length

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
charcode ^1.1.2 1.1.2
csslib ^0.14.5 0.14.6
html ^0.13.3 0.13.3+3
meta ^1.1.7 1.1.7
Transitive dependencies
args 1.5.1
logging 0.11.3+2
path 1.6.2
source_span 1.5.4
term_glyph 1.1.0
utf 0.9.0+5
Dev dependencies
pedantic ^1.0.0
test ^1.4.0