Skip to content

Flutter bundles assets from all packages in a pub workspace #160142

@josh-burton

Description

@josh-burton

When using the new pub workspaces, I've found a bug where assets from all packages are bundled in the built app, rather than assets from just the packages that the Flutter app depends on.

This seems to occur when packages in the workspace depend on a common shared package - in this case one called base.

Steps to reproduce

Given a Flutter monorepo that uses pub workspaces in this setup:

  • base - a Flutter package with an asset
  • included_package - a Flutter package with an asset that depends on base
  • excluded_package - a Flutter package with an asset that depends on base
  • app - a Flutter app that depends on ONLY included_package

Build the app via flutter build web in the app package.

Expected results

A Flutter app is built containing only the assets from included_package.

Actual results

A Flutter app is built containing the assets from all packages.

Code sample

Code sample See this Github repo for a sample: https://github.com/josh-burton/flutter_workspace_assets_bug

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64, locale en-NZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3.1)
[✓] VS Code (version 1.95.3)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for Ark iPhone (2). Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: assetsPackaging, accessing, or using assetsa: buildBuilding flutter applications with the toolfound in release: 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions