What's the difference between "dart:html" and "dart:dom" package?

Issue

I’m starting with some of the Dart examples. Then I wanted to query the DOM with document.query('#someId') as described here, but it seems there was no query method in document. Also creating a new element by `new Element.tag(‘p’) doesn’t work.

Then I figure out that it will work, when I change the imported package from dart:dom to dart:html. But using both of them gives me a bunch of duplicate definition of _XYZ.

So I wonder:

  1. what’s the difference between dart:html and dart:dom package
  2. which one should I use
  3. why can’t I use both

Solution

An update to all the answers, and probably makes this question no longer applicable is that dart:dom has been deprecated.

See this post on dartlang website.

Answered By – Chris Buckett

Answer Checked By – Senaida (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *