Skip to content

Fix package root resolution after build_runner 2.14.0 AOT changes#750

Merged
AlexV525 merged 2 commits intoFlutterGen:mainfrom
Carapacik:main
Apr 25, 2026
Merged

Fix package root resolution after build_runner 2.14.0 AOT changes#750
AlexV525 merged 2 commits intoFlutterGen:mainfrom
Carapacik:main

Conversation

@Carapacik
Copy link
Copy Markdown
Contributor

@Carapacik Carapacik commented Apr 23, 2026

What does this change?

This fixes package root resolution in flutter_gen_runner after the build_runner 2.14.0 change that runs build / watch through AOT by default.

Previously, FlutterGenBuilder relied on Isolate.packageConfigSync! as the only source for package roots. With the newer AOT build-script flow, the runtime isolate package config can be null or no longer represent the active build graph, which may crash the builder or fail to resolve the target package root, especially on Windows.

The package root is now resolved in this order:

  1. Use BuildStep.packageConfig as the primary source for the active build graph.
  2. Fall back to the runtime isolate package config when available.
  3. Fall back to discovering the package from .dart_tool/package_config.json or a matching pubspec.yaml under the current working directory.

This also removes the eager static runtime package config load, avoiding the null assertion crash from Isolate.packageConfigSync!.

Fixes #749 🎯

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
    • Ensure the tests (melos run test)
    • Ensure the analyzer and formatter pass (melos run format to automatically apply formatting)
  • Appropriate docs were updated (if necessary)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.37%. Comparing base (59626d9) to head (15c4103).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #750   +/-   ##
=======================================
  Coverage   97.37%   97.37%           
=======================================
  Files          24       24           
  Lines         991      991           
=======================================
  Hits          965      965           
  Misses         26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@AlexV525 AlexV525 merged commit c839ac2 into FlutterGen:main Apr 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: build error on build_runner 2.14.0

2 participants