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

♀尐吖头ヾ 提交于 2019-11-29 08:19:08

问题


Suppose I have two dart projects

Project A contains code that uses web component to create bunch of UI widget (similar to https://github.com/kevmoo/widget.dart)

Project B contains my front end code that would reuse the UI widget I created in project A.

If I dont want to publish my project A to pub, is there anyway to link project B to project A without manually copying files from project A into B?

Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/15774030/dart-how-does-one-dart-project-import-code-from-another-dart-project-without-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!