When Dart sees an import like:
import 'package:foo/foo.dart';
It translates it to:
import '<url of your entrypoint>/packages/foo/foo.dart';
So, say your app's entrypoint is in:
myapp/web/app/main.dart
If it has a "package:" import, like above, it will remap it to:
import 'myapp/web/app/packages/foo/foo.dart';
That means that for Dart to be able to find foo.dart
, there needs to be a packages
directory inside app
that contains foo/foo.dart
. Part of pub's job is to set that up for you.
This is definitely not the nicest part of working with Dart and pub. Spewing symlinks everywhere is gross, but it deals with the limitations that the language places on us. Over time, we're hoping to move away from having to create these symlinks.
More details on this here.