module - 如何组织多包flutter项目并将其用作依赖项

标签 module dart flutter dart-pub flutter-dependencies

我想将一个 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/

    相关文章:

    module - 为什么从 modules.perl6.org 的 rsync 中排除 PSIXDISTS?

    Flutter Layout : How can I put a Row inside a Flex (or another Row) in Flutter? 同样使用 Stack 小部件

    android - 无法更新 Dart SDK。重试

    flutter - 如何在 Flutter 创建的应用程序中隐藏 AppBar

    grails - 使用 Intellij 在 Groovy/Grails 应用程序中添加模块依赖

    Python:优化模块导入

    javascript - JavaScript 中的静态导入

    flutter - 对象列表中的 Dart flutter 最大值

    flutter - Flutter代码是否容易进行反向工程而不会引起混淆?

    firebase - 在 initState() flutter 中使用异步方法