Dart - How does one dart project import code from another dart project without using pub? Dart - How does one dart project import code from another dart project without using pub? dart dart

Dart - How does one dart project import code from another dart project without using pub?


Take a look at this section in the pub documentation: Path Dependencies:

http://pub.dartlang.org/doc/dependencies.html#path-packages

Suppose project_a had a library file called myprojecta.dart

dependencies:  project_a:    path: /Users/me/project_a   <-- root of project a

In your code, you would import project_a using

import 'package:project_a/myprojecta.dart'

Note - if you don't want to publish your project to pub, you can always use git as a dependency rather than path dependency - this lets other people in your team use your projects without relying upon your filesystem layout.