我想将一个 flutter 项目组织成一个具有以下要求的多包项目:
我现在拥有的存储库的文件设置是:
.
├── app_base
│ ├── ...
│ └── pubspec.yaml
├── feature
│ ├── ...
│ └── pubspec.yaml
└── README.md
我尝试在
app_base/pubspec.yaml
中使用这样的路径依赖项:name: app_base
dependencies:
feature:
path: ../feature
它适用于本地开发,但如果我尝试使用
app_base
在一个完全不同的项目中,不使用路径而是使用 git 依赖项:name: actual_app
dependencies:
app_base:
git:
url: ssh://address.to/the_repo.git
path: app_base
ref: deadbaca
它无法解析传递
feature
依赖:Running "flutter packages get" in actual_app...
Error on line 21, column 11: Invalid description: "../feature" is a relative path, but this isn't a local pubspec.
path: ../feature
^^^^^^^^^^
pub get failed (65)
Process finished with exit code 65
有没有办法让它既适用于本地开发又用作其他项目的 git 依赖项?
最佳答案
只需对这两种场景(本地和其他项目)使用 Git 依赖项。
如果在本地开发时觉得这样比较麻烦,可以在本地使用路径fependencies,在提交前改回Git。
关于module - 如何组织多包flutter项目并将其用作依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54555612/