Skip to content

Skip platform tooling regeneration for non-Flutter pub workspace packages - #189705

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
UditDewan:fix-pub-get-non-flutter-workspace-root
Aug 5, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
UditDewan:fix-pub-get-non-flutter-workspace-root

Conversation

@UditDewan

Copy link
Copy Markdown
Contributor

flutter pub get post-processing iterates every workspace root package listed in .dart_tool/package_graph.json and unconditionally regenerates platform-specific tooling for each of them. Since regeneratePlatformSpecificTooling gates only on whether platform directories exist on disk, a pub workspace root that is a plain Dart package (no dependency on Flutter) with a stray ios/ or android/ directory got that directory populated with Flutter project files (GeneratedPluginRegistrant.*, Generated.xcconfig, flutter_export_environment.sh, ...).

This PR skips platform tooling regeneration for workspace packages that do not depend on the flutter package, directly or transitively, according to the resolved package graph. Checking the transitive closure (rather than just the direct dependencies of the pubspec) keeps workspace members that only depend on Flutter through another package (e.g. an app that only declares a dependency on a plugin) working exactly as before, which is covered by the existing test get creates plugin registrants for each app in workspace.

Adds a regression test that sets up a workspace whose root is a plain Dart package with empty ios/ and android/ directories, and verifies that flutter pub get leaves them empty while still processing the Flutter app member of the workspace. The test fails before this change (ios/ gains Runner/ and Flutter/ directories) and passes after it.

Fixes #189550

Pre-launch Checklist

…ages

`flutter pub get` regenerates platform-specific tooling for every
workspace root package listed in package_graph.json. A pub workspace
root that is a plain Dart package was processed too, so a stray ios/ or
android/ directory at the workspace root was populated with Flutter
project files (GeneratedPluginRegistrant, Generated.xcconfig, etc.).

Skip packages that do not depend on flutter, directly or transitively,
according to the resolved package graph. Workspace members that are
Flutter apps are still processed, including apps that only depend on
Flutter transitively (e.g. through a plugin).

Fixes flutter#189550
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 19, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request prevents regenerating platform-specific tooling for workspace packages that do not depend on Flutter, addressing a regression where plain Dart workspace roots were populated with Flutter project files. It introduces a helper method to check for transitive dependencies on Flutter and adds a corresponding test. The review feedback suggests a minor refactoring in the dependency traversal logic to avoid using a null-coalescing operator with an empty list fallback, improving efficiency and readability.

if (current == 'flutter') {
return true;
}
toVisit.addAll(graph.dependencies[current] ?? const <String>[]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of using the null-coalescing operator with a constant empty list fallback (?? const <String>[]), we can retrieve the dependencies list and only call addAll if it is non-null. This avoids referencing the fallback list and calling addAll on an empty list, making the code slightly cleaner and more efficient.

      final List<String>? dependencies = graph.dependencies[current];
      if (dependencies != null) {
        toVisit.addAll(dependencies);
      }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@bkonyi

bkonyi commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR @UditDewan! This looks good to me overall, just a couple of minor comments before I can approve.

/// transitively, according to the resolved package [graph].
static bool _dependsOnFlutter(PackageGraph graph, String packageName) {
final visited = <String>{};
final toVisit = <String>[packageName];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we should use a Queue here instead of a List.

if (current == 'flutter') {
return true;
}
toVisit.addAll(graph.dependencies[current] ?? const <String>[]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@bkonyi bkonyi added the CICD Run CI/CD label Aug 4, 2026
Switch the pending-package worklist in _dependsOnFlutter from a List to
a Queue, and read the dependency list into a local instead of falling
back to a constant empty list.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 4, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Aug 4, 2026
@bkonyi
bkonyi requested a review from chingjun August 4, 2026 16:24
@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 4, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 4, 2026
@auto-submit

auto-submit Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189705, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 4, 2026
@bkonyi bkonyi added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Aug 4, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 4, 2026
@auto-submit

auto-submit Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189705, because - The status or check suite Tree_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 4, 2026
@bkonyi bkonyi added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Aug 4, 2026
@auto-submit

auto-submit Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189705, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 4, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 5, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: stable cherry pick this pull request to stable release candidate branch tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter pub get regenerates Flutter platform tooling (ios/android) in non-Flutter pub workspace root packages

3 participants