You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use flutterRoot instead of looking for the flutter package when reading the sdk path from .package_config.json #5728
Is your feature request related to a problem? Please describe.
Right now extractFlutterSdkPathFromPackagesFile tries to read the path to the "flutter" package and this works well for flutter projects, but does not work for pure dart projects.
Describe the solution you'd like
In ".package_config.json" there seem to be a field called "flutterRoot" which points to the sdk and is present regardless of the flutter package (and even created when running "dart pub get", though I have flutter installed on my device).
For tools like asdf the location of the sdk is dynamic and after reading this comment #5377 (comment) I though that it can work for pure dart projects as well but now I'm not sure that you actually want to always find the flutter sdk here (and below)
What I can tell is that you try to transform the path in extractFlutterSdkPathFromPackagesFile (remove unnecessary parts), but the flutterRoot already has the correct path. Why not to simplify it?
I'm not sure, I'd have to look up when it's populated to understand how it would change what we have today. I wanted to understand if there was a situation you had in mind where this would improve/change something (I wasn't sure if you'd hit a problem that you thought this would fix).
What I can tell is that you try to transform the path in extractFlutterSdkPathFromPackagesFile (remove unnecessary parts), but the flutterRoot already has the correct path. Why not to simplify it?
I did some testing, and this field is populated for non-Flutter Dart packages if you use the Dart SDK from a Flutter SDK so we'd need to be careful not to use this as a signal that this project is Flutter (however the current call for this function already checks that). So maybe it's worth changing (to avoid some extra path manipulation) as long as we make that behaviour clear.
For tools like asdf the location of the sdk is dynamic and after reading this comment #5377 (comment) I though that it can work for pure dart projects as well
There is an equivalent dart.getDartSdkCommand setting for non-Flutter projects, but I don't know if it handles what you had in mind?
There is an equivalent dart.getDartSdkCommand setting for non-Flutter projects, but I don't know if it handles what you had in mind?
That is not an equivalent in a sense that it requires manual setup.
I personally don't use asdf, so again, feel free to close this if you don't see this as an improvement. IMO, finding the sdk automatically is always better than asking for a manual setup. That's why I opened this issue.
That is not an equivalent in a sense that it requires manual setup.
I'm not sure I understand - the getFlutterSdkCommand version you linked also requires manual setup. They are two settings that allow us to call our to external tools to get the SDK paths, one for Dart, one for Flutter. If you use something like asdf you still need to configure it so we run the correct command.
IMO, finding the sdk automatically is always better than asking for a manual setup.
I absolutely agree with this (which is why we search many places for SDKs!), but I don't think switching from the flutter package path in package_config.json to flutterRoot will change any behaviour here, it will just simplify our path manipulation (avoiding us having to strip packages/flutter off the end to find the SDK root.
Activity
DanTup commentedon Sep 27, 2025
It's not clear to me why we would want to find the Flutter SDK from pure dart projects - are you having a problem that you think this would solve?
incendial commentedon Sep 27, 2025
For tools like asdf the location of the sdk is dynamic and after reading this comment #5377 (comment) I though that it can work for pure dart projects as well but now I'm not sure that you actually want to always find the flutter sdk here (and below)
Dart-Code/src/extension/sdk/utils.ts
Line 407 in 3c0f98c
What I can tell is that you try to transform the path in
extractFlutterSdkPathFromPackagesFile(remove unnecessary parts), but theflutterRootalready has the correct path. Why not to simplify it?incendial commentedon Sep 27, 2025
If you don't see that as an improvement for the sdk detection, feel free to close the issue
DanTup commentedon Sep 27, 2025
I'm not sure, I'd have to look up when it's populated to understand how it would change what we have today. I wanted to understand if there was a situation you had in mind where this would improve/change something (I wasn't sure if you'd hit a problem that you thought this would fix).
DanTup commentedon Oct 1, 2025
I did some testing, and this field is populated for non-Flutter Dart packages if you use the Dart SDK from a Flutter SDK so we'd need to be careful not to use this as a signal that this project is Flutter (however the current call for this function already checks that). So maybe it's worth changing (to avoid some extra path manipulation) as long as we make that behaviour clear.
There is an equivalent
dart.getDartSdkCommandsetting for non-Flutter projects, but I don't know if it handles what you had in mind?incendial commentedon Oct 1, 2025
That is not an equivalent in a sense that it requires manual setup.
I personally don't use asdf, so again, feel free to close this if you don't see this as an improvement. IMO, finding the sdk automatically is always better than asking for a manual setup. That's why I opened this issue.
DanTup commentedon Oct 2, 2025
I'm not sure I understand - the
getFlutterSdkCommandversion you linked also requires manual setup. They are two settings that allow us to call our to external tools to get the SDK paths, one for Dart, one for Flutter. If you use something likeasdfyou still need to configure it so we run the correct command.I absolutely agree with this (which is why we search many places for SDKs!), but I don't think switching from the
flutterpackage path inpackage_config.jsontoflutterRootwill change any behaviour here, it will just simplify our path manipulation (avoiding us having to strippackages/flutteroff the end to find the SDK root.Read flutterRoot from package_config.json instead of parsing up the f…