Error: Couldn't resolve the package Flutter / Dart Origin: On your device OSI layer 7 · Application Last updated 4 Nov 2026

Dart: Error: Couldn't resolve the package 'x' in 'package:x/x.dart'

Code imports a package that is not in pubspec.yaml or pub get has not been run since adding it.

Exact message you may see Error: Couldn't resolve the package in package:Target of URI doesn't exist: 'package:Couldn't resolve the package 'http' in 'package:http/http.dart'Not found: 'package:x/x.dart'Could not resolve the package
Seen on: Flutter

Meaning

Add the dependency (flutter pub add x), run flutter pub get, and restart the IDE/analysis server. Also check the import path spelling and that the package name in the import matches the package's name: (dashes vs underscores).

Common causes

  • Dependency missing from pubspec.yaml
  • pub get not run
  • Typo in package name or import path
  • Package named differently than expected
  • Stale .dart_tool/package_config.json

⚡ Quick fix

  1. flutter pub add package_name
  2. flutter pub get and restart the Dart analysis server
  3. Delete .dart_tool and re-run pub get

Detailed fix by platform

Flutter

  1. flutter pub add http && flutter pub get

How to diagnose

  1. Pubspec — Dependency listed?
  2. Pub get — Run?
  3. Name — Spelled correctly?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Bad state: No element — Dart: Bad state: No element — .first, .last or .single on an empty list (Flutter / Dart)Bad state: No elementBad state: Stream has already been listened to — Dart: Bad state: Stream has already been listened to (Flutter / Dart)Bad state: Stream has…FormatException: Unexpected character — Dart: FormatException: Unexpected character (at character 1) <!DOCTYPE html> — jsonDecode of an HTML page (Flutter / Dart)FormatException: Unex…Illegal argument in isolate message: object is unsendable — Dart: Invalid argument(s): Illegal argument in isolate message: object is unsendable - Library:'dart:async' Class: _Future@4048458 (Flutter / Dart)Illegal argument in i…Non-nullable instance field must be initialized — Dart: Non-nullable instance field 'name' must be initialized. Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late' (Flutter / Dart)Non-nullable instance…Null check operator used on a null value — Dart/Flutter: Null check operator used on a null value (Flutter / Dart)Null check operator u…RangeError (index): Invalid value — Dart: RangeError (index): Invalid value: Valid value range is empty: 0 (Flutter / Dart)RangeError (index): I…The argument type can't be assigned to the parameter type — Dart: The argument type 'String?' can't be assigned to the parameter type 'String' (Flutter / Dart)The argument type can…Error: Co…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.