2
votes

Anyone know how to use 'Path packages?' Ref: https://www.dartlang.org/tools/pub/dependencies#path-packages

I tried bring in another app called 'mvc' and it doesn't like the path: ../mvc/

name: startup_namer
description: A new Flutter application.

dependencies:
  flutter:
    sdk: flutter

  mvc:
    path: ../mvc/

It finds the mvc's package file, pubspec.yaml, but I think it's complaining the folder is not in this project's content (Whatever that means?!)

Here is the error message:

Folder C:\Programs\Tools\Projects\Flutter\mvc is not in project content less... (Ctrl+F1) 

This inspection works in pubspec.yaml file and checks path references for dependencies configured as Path Packages:

Path must be valid and target folder must contain pubspec.yaml file.

Path Package should be within the project content, otherwise files from such packages are not editable.

Example of pubspec.yaml file: 
name: my_dart_project
version: 0.0.1
dependencies:
  my_another_dart_project:
    path: ../my_another_dart_project

Does it want the folder, mvc/, 'within' the other project's directory??

1
Please add the directory structure, otherwise there is not way we can verify anything.Günter Zöchbauer
I figured this out by using absolute path for package development. path: /Users/username/path/to/package.SacWebDeveloper

1 Answers

4
votes

Despite it continuing to 'complain' about the it not being in the project content, it works. You just can't edit the files (which of course you can --- just in their own project.)

The trick to now successfully import the dart files is to, while viewing the file, pubspec.yaml, is to now perform a pub action (eg. 'Get dependencies' or 'Upgrade dependancies').

They're links up in the top right-hand corner of the window. The commands themselves might even execute with an error code, but you'll find your external system file package now listed under Dart packages while in 'Project View'.

Package comes in after performing an unsuccessful Pub action.