Artur Stepniewski
Artur Stepniewski

Reputation: 1491

How to organise multi package flutter project and use it as dependency

I would like to organise a flutter project into a multi-package one with following requirements:

The file setup for the repository I have now is:

.
├── app_base
│   ├── ...
│   └── pubspec.yaml
├── feature
│   ├── ...
│   └── pubspec.yaml
└── README.md

I tried using path dependencies like this in app_base/pubspec.yaml:

name: app_base

dependencies:
  feature:
    path: ../feature

and it works for local development but if I try to use app_base in a completely different project and not use paths but a git dependency:

name: actual_app

dependencies:
  app_base:
    git:
      url: ssh://address.to/the_repo.git
      path: app_base
      ref: deadbaca

it cannot resolve the transitive feature dependency:

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

Is there a way to make it work for both local development and used as a git dependency from other project?

Upvotes: 6

Views: 3017

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657376

Just use Git dependencies for both scenarios (locally and for other projects).

If you think this is cumbersome during local development, use path dependencies locally and change it back to Git before committing.

Upvotes: 1

Related Questions