Skip to content

[feature request] add workspace dependency syntax support for pubspec.yaml #4790

@luo2430

Description

@luo2430

Info

- Dart 3.11.0 (stable) (Mon Feb 9 00:38:07 2026 -0800) on "windows_x64"
- on windows / "Windows 11 家庭版" 10.0 (Build 26200)
- locale is zh-CN

Currently, when using pub workspace, the local package in pubspec.yaml references the local package in the workspace is written exactly the same as the dependency reference to the external pub.dev. This syntactic ambiguity can lead to the inability to visually distinguish between local dependencies and external dependencies.

pubspec.yaml for pub

# local
flutter_package_1:
flutter_package_1: any
flutter_package_1: ^0.0.1

# external
flutter_lints:
flutter_lints: any
flutter_lints: ^6.0.0

package.json for pnpm

// local
"common-utils": "workspace:*"
"common-utils": "workspace:^0.0.1" // This version can be written, but it will actually be ignored

// external
"@types/node": "*"
"@types/node": "^25.3.3"

Expected

Referring to pnpm workspace dependency syntax, I expect to introduce a similar explicit workspace dependency declaration for pubspec.yaml.

flutter_package_1: workspace
flutter_package_1: workspace:any
flutter_package_1: workspace:^0.0.1

# or
flutter_package_1:
  workspace:
flutter_package_1:
  workspace: any
flutter_package_1:
  workspace: ^0.0.1

https://github.com/luo2430/dart_pub_issue_4790

The project directory is shown in the image below

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions