Dart-Code: dart.flutterSdkPath setting in vscode's settings.json is a user specific absolute path causing the file to become unsharable

Is your feature request related to a problem? Please describe. I’m dissapointed that when i configure my chosen flutter sdk with vs-code it puts an absolute path in the settings.json file. This causes this file to become unsharable across our team.

To illustrate some use cases where this becomes a problem:

  • Our team is comprised of full-stack developers who do both flutter and backend work. Often times we put our app and backend for frontend code into one repository for simplicity. Extensions for backend code also put settings here, but these are not user specific and need to be shared.
  • Cross platfrom development. I for example do flutter development on both Windows and MacOS so the start of the paths are not going to be compatible “/” vs “C:\”

Describe the solution you’d like I would like this setting to not be stored in a way that is user specific. I think there are multiple options to handle this, some are listed below with some being beter then others. A completely differnt solution is also acceptable. As long as it means i can check settings.json into git and use it across my team and across operating systems.

Home Directory

You can make a soft rule that all flutter sdks need to be installed in the users home directory. Teams can then decide on a structure for example ~/flutter-sdks where the sdk’s are stored like:

  • ~/flutter-sdks/flutter-sdk-3.3.10
  • ~/flutter-sdks/flutter-sdk-3.7.12
  • ~/flutter-sdks/flutter-sdk-3.10.5

the settings.json file would then look like this

{
"dart.flutterSdkPath" : "flutter-sdks"
}

Downside is that you become very limited on where you might want to store you sdks. Many people like to install them in the root of the file system for example.

Only store sdk version

Only store the flutter sdk version you want to store in the settings.json. This way only the important thing is shared. It’s the up to the user to provide VS-code with a path to his flutter sdks just like it is now.

Possible downside is you don’t want to store a absolute path in user settings either since these can be synced across devices and then you run into the Windows vs Mac issue again.

{
"dart.flutterSdkVersion" : "3.7.12"
}

Store the current setting in a different file

instead of saving

{
"dart.flutterSdkPath": "/Users/jorenthijs/Developer/tools/flutter-sdks/flutter_3.7.12"
}

in vs-code settings.json you could create a new .vs-code folder file that is meant to be user specific and that can then be added to .gitignore. For example “.vs-code/dart-sdk-user-settings.json”

The only downside here being there will be no way to share a setting for which flutter version your app uses across your team.

Describe alternatives you’ve considered I considered and tried third party solutions like FVM but these did not work properly and required to many workarounds.

Additional context For additional context here is one of my current settings.json files from a repository that contains both flutter and C# code. As you can see the C# code extension also puts directory related settings in here but these are relative to the repository and thus work cross platform and cross team. image

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

No problem - please do file additional issues of other things come up. Thanks!

I’ve opened https://github.com/Dart-Code/Dart-Code/issues/4708 to track doing that specifically.

Thanks for the comprehensive answer Dan! I’ll take these options for a spin and see if they help. I’ve never used the VS-code workspace feature since i always just open the repository folder so i’m curious to try.

I’ll try to keep you posted. if you don’t hear back from me in two weeks feel free to close this issue👍

Thanks!