0
votes

I sucessfully split up a flutter mobile application in to packages. One package is referenced by the flutter mobile app by using the following in the pubspec.yaml:

app:
  path: /path/app

The fultter app builds and runs just fine and no problem is reported by the IDE (visual code) when it does the 'pub get'

When I do the same thing in the web-project the IDE complains on 'pub get' with:

Error on line 8, column 5 of pubspec.yaml: A version constraint must be a string.

When trying to build web project by issuing the command:

webdev build

I get the following error:

build_web_compilers:entrypoint on web/main.dart (cached): Unable to find modules for some sources, this is usually the result of either a bad import, a missing dependency in a package (or possibly a dev_dependency needs to move to a real dependency), or a build failure (if importing a generated file).

I even tried to use Windows native top level path (C:\path\package) but without a changed outcome. It seems that webdev does not support local path packages like described by the official PackageDependencies | Dart manual page.

1

1 Answers

0
votes

When using shorthand and creating the web project it does not create a dependencies section in the pubspec.yaml file. I added another dependency (package) right under the environment section where the SDK is also configured.

It does not complained about the package dependency being under environment but it complains about a package dependency that has no version but a path.

I only noticed when I used a symlink to add the lib's source folder (lib) directly to the web project as it kept complaining about not finding this said package dependency.

Checking the packages file the package was not mentioned and in the pubspec.lock file the package was listed under the 'sdks:' section.

By creating a 'dependencies:' section and putting both dependencies under it, it now works as intended... . Case closed!