fvm icon indicating copy to clipboard operation
fvm copied to clipboard

Best practice for switching to a different Flutter version?

Open nilsreichardt opened this issue 2 years ago • 5 comments

We want to use FVM in our team to ensure a consistent Flutter version across our team. From reading the docs, I can't find a good solution for switching to a new Flutter version.

We have committed the fvm_config.json, but the flutter_sdk is ignored by git (as described in the docs). What is now the process to switch to a new Flutter version? I would assume the following steps:

  1. Change the version in fvm_config.json
  2. Run fvm install

But now the problem: Every other developer needs to be notified, that their need to run fvm install, otherwise they will use a different version, right?

I would love to hear of a better solution and add this to the FAQ section of the docs.

nilsreichardt avatar Apr 23 '22 14:04 nilsreichardt

@nilsreichardt if a commit changes version there, I believe either they would need to be notified or could be part of an internal tool or process to do that. But again I am not sure how often this happens.

Maybe an implementation using git hooks might be what you need, here is a great article on it.

https://dev.to/arthurdenner/git-hooks-in-flutter-projects-with-lefthook-52n

leoafarias avatar Apr 23 '22 20:04 leoafarias

FVM automatically asks you to install the new version if it was changes in the fvm_config.json file. There is no need to run fvm install, any other command will ask you to install.

I found this to be working quiet well in a team, no need for any notification to update flutter. For apps we additionally update the minimum flutter constraint in pubspec.yaml but if every developer uses FVM, there is nothing to worry about.

You can also use the fvm_config.json file to read and install the version in CI.

kuhnroyal avatar Apr 23 '22 22:04 kuhnroyal

@kuhnroyal does this would apply if running the CLI but I believe if not running from the IDE tooling…

leoafarias avatar Apr 24 '22 01:04 leoafarias

hmm yeah, if one only uses IDE, this is a problem.

kuhnroyal avatar Apr 24 '22 14:04 kuhnroyal

I think a solution is to set also the flutter version in the pubspec.yaml:

environment:
  sdk: '>=2.18.0 <3.0.0'
  flutter: 3.3.2

Therefore, other people can't use unintentionally the old flutter version 👍

nilsreichardt avatar Sep 16 '22 11:09 nilsreichardt

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 02 '22 20:12 stale[bot]