Fix package root resolution after build_runner 2.14.0 AOT changes by Carapacik · Pull Request #750 · FlutterGen/flutter_gen · GitHub
Skip to content

Fix package root resolution after build_runner 2.14.0 AOT changes#750

Open
Carapacik wants to merge 2 commits intoFlutterGen:mainfrom
Carapacik:main
Open

Fix package root resolution after build_runner 2.14.0 AOT changes#750
Carapacik wants to merge 2 commits intoFlutterGen:mainfrom
Carapacik:main

Conversation

@Carapacik
Copy link
Copy Markdown

@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

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

1 participant