What to do if I have a "Do not know how to load 'dart:html' " when loading library?

dart, import, libraries

Solution

dart:html specifically is only available in the browser side. This looks like you are trying to run a client side script with dart.exe on the server side.

dart:html is available on the browser (and interacts with the DOM) dart:io is available on the server (and interacts with the OS)

Problem

The first two lines in my dart library are: ``` #library('LibraryName'); #import('dart:html'); ``` When I try to load the library from another .dart file with ``` #import('../path/to/LibraryName.dart'); ``` I get the following error: ``` Do not know how to load 'dart:html''file:///the/path/to/LibraryName.dart': Error: line 2 pos 1: library handler failed #import('dart:html'); ^ ``` The `#import('dart:html')` works fine when I use the library as a standalone app, but I want to be able to access it as a library from another dart app. How can I use the library?

Original source