Dart - 一个dart项目如何从另一个dart项目导入代码而不使用pub? [英] Dart - How does one dart project import code from another dart project without using pub?
问题描述
假设我有两个dart项目
Project A包含使用web组件创建一系列UI窗口部件的代码(类似于 https://github.com/kevmoo/widget.dart )
项目B包含我的前端代码,可以重用我在项目A中创建的UI小部件。
如果我不想将我的项目A发布到pub,
$ p请参阅 pub
文档中的此部分:路径依赖关系:
http://pub.dartlang.org/doc/dependencies.html#path-packages
假设 project_a
有一个名为 myprojecta.dart的库文件
p>
依赖项:
project_a:
path:/ Users / me / project_a<
在您的代码中,您将导入 project_a
使用
import'package:project_a / myprojecta.dart'
注意 - 如果你不想将你的项目发布到pub,你总是可以使用 git
而不是 path
依赖关系 - 这可以让您团队中的其他人在不依赖于您的文件系统布局的情况下使用您的项目。
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
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.
这篇关于Dart - 一个dart项目如何从另一个dart项目导入代码而不使用pub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!