Explanation:
The error message “publishable packages can’t have ‘git’ dependencies” generally occurs when publishing a package that has a dependency on a Git repository. When publishing packages, it is recommended to only include production-ready dependencies from package repositories like npm.
To resolve this issue, there are two possible solutions:
-
Add a ‘publish_to: none’ entry:
// pubspec.yaml name: your_package_name version: 1.0.0 dependencies: some_dependency: ^1.0.0 publish_to: none
By adding the ‘publish_to: none‘ entry in your pubspec.yaml file, you can mark the package as not for publishing. This helps if you intend to use the package only for internal purposes and do not want to make it publicly available on the package repository.
-
Remove the Git dependency:
If the Git dependency is not necessary for your package to function properly, you can remove it from your pubspec.yaml file.
// pubspec.yaml name: your_package_name version: 1.0.0 dependencies: some_dependency: ^1.0.0
It’s always recommended to use dependencies that are available on package repositories like npm, as they are more stable and reliable.