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
- Avoid dart:html in non-web builds; guard with conditional imports.
- Use
package:webor conditional imports for cross-platform code. - 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 getHow to prevent it
- Use conditional imports for platform libraries.
- Run pub get before analyze/build.
- List every imported package in pubspec.
Related guides
Dart pub "version solving failed" in CIFix Dart "pub get" version solving failed in CI when package constraints conflict or the Dart/Flutter SDK bou…
Dart "command not found" in CIFix "dart: command not found" / unknown pub subcommand in CI - the Dart SDK is not installed or not on PATH,…
Elixir MatchError failing tests in CIFix Elixir "(MatchError) no match of right hand side value" failing tests or builds in CI - a pattern match d…