How to import a library from the lib folder in my web application?

My folder structure is as follows:

lib\
    my_library.dart
web\
    index.html
    main.dart
pubspec.yaml

In main.dartI import my_library.dart(at which library my_libraryabove), doing:

import '../lib/my_library.dart';

It works great. However, it feels a little fragile to have this relative path. I read in Publishing Package Conventions , which I can probably use import 'package:blah'; He says:

When you use libraries from your own package, even code in src, you can (and should) still use "package:" to import them

So, I tried changing my code to this:

import 'package:my_library.dart';

However, in the Chrome Dev editor, I get:

The target or URI does not exist: 'package: grid_data.dart'

and in Dartium I get:

GET http://127.0.0.1:51792/MyProject/web/packages/my_library.dart 404 ( )

- lib dart ?

+4
1

import 'package:my_project/my_library.dart';

package: my_project (, pubspec.yaml. - , . < > DartEditor , , .
my_project, my_project/lib.

+9

All Articles