Skip to content
Latchkey

Dart "Not found: dart:X" / package URI error

The Dart compiler could not resolve an import URI. A platform-specific library is unavailable on the target, or a package import was not resolved.

What this error means

Compilation fails with Error: Not found: dart:html or Not found: package:foo/foo.dart, pointing at the import. It is deterministic.

dart
lib/web_util.dart:1:8: Error: Not found: 'dart:html'
import 'dart:html';
       ^

Common causes

Platform library not on the target

dart:html is web-only and dart:io is not available on web. Importing one on the wrong platform fails.

Package not in dependencies

A package: import references a package not listed in pubspec.yaml, so it does not resolve.

pub get not run

Dependencies were not fetched before compiling, so package URIs are unresolved.

How to fix it

Use platform-appropriate libraries

  1. Avoid dart:html in non-web builds; guard with conditional imports.
  2. Use package:web or conditional imports for cross-platform code.
  3. Keep dart:io out of web targets.

Add the package and resolve

Declare the dependency and fetch it before building.

CI step
dart pub add http
dart pub get

How to prevent it

  • Use conditional imports for platform libraries.
  • Run pub get before analyze/build.
  • List every imported package in pubspec.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →