Armand Grillet
Armand Grillet

Reputation: 3399

Failed to load package in Dart

When I try to import a package with the syntax import 'package:markdown/markdown.dart';, I get no error in Dart Editor but when I run the dart application, the debugger shows me the message:

An error occurred loading file: package:markdown/markdown.dart
Failed to load resource
  chrome-extension://gfjabgeipkcfopofkhjimepepnomcidk/dart/packages/markdown/markdown.dart

But when I write the whole path (import "../../packages/markdown/markdown.dart";) everything works fine. I cannot understand why the syntax package: doesn't work in my code though it works in Dart Editor's own examples.

You can see the Chrome app architecture below (I'm loading a package from translator.dart):

Application architecture

Upvotes: 0

Views: 844

Answers (2)

markovuksanovic
markovuksanovic

Reputation: 15906

You should have the package added as a dependency in pubspec.yaml (which I assume you do).

Also try running following:

  • delete packages folder
  • delete pubspec.lock
  • run pub get to fetch the dependencies again.

Upvotes: 1

user2685314
user2685314

Reputation: 1069

I think in your md_to_html folder you need a link to the 'packages' directory for the shortform to work. I seem to remember this happening when the workspace is built but I'm not sure now which command triggers it, have a look at the current pub docs.

Upvotes: 0

Related Questions