Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • use one repository for this project
  • able for developers to work on the packages in this repository locally
  • make the packages accessible as dependencies from other projects outside of this repository

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?

like image 795
Artur Stepniewski Avatar asked Nov 17 '22 16:11

Artur Stepniewski


1 Answers

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.

like image 142
Günter Zöchbauer Avatar answered May 12 '23 07:05

Günter Zöchbauer