Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer Flutter version from pubspec.yaml #211

Closed
bartekpacia opened this issue Mar 19, 2023 · 2 comments
Closed

Infer Flutter version from pubspec.yaml #211

bartekpacia opened this issue Mar 19, 2023 · 2 comments

Comments

@bartekpacia
Copy link
Collaborator

bartekpacia commented Mar 19, 2023

I find it a bit annoying that whenever I update Flutter, I have to change the version in pubspec.yaml and in my GitHub Actions workflows.

I think it'd be great if this action would infer Flutter version from pubspec.yaml:

- name: Set up Flutter
  uses: subosito/flutter-action@v2
  with:
    # channel: stable  # not needed - stable would be used by default
    # flutter-version: '3.7.0' # not needed - would be inferred `pubspec.yaml`
    architecture: x64
    cache: true

This approach is used in, for example, the actions/setup-go:

- uses: actions/setup-go@v4
  with:
    go-version-file: go.mod

Of course, it'd still be possible to explicitly specify the Flutter version to use.

@kuhnroyal
Copy link
Contributor

Which version would you infer from >= 3.5.0 <4.0.0?
I suggest you look at https://github.com/fluttertools/fvm and https://github.com/kuhnroyal/flutter-fvm-config-action if you want to manage the version in one place.

@bartekpacia
Copy link
Collaborator Author

bartekpacia commented Mar 19, 2023

@kuhnroyal Thanks for showing https://github.com/kuhnroyal/flutter-fvm-config-action – looks nice and like something that is a way to solve this problem.

Which version would you infer from >= 3.5.0 <4.0.0?

The minimum one. It's a good practice to keep the lower bound of flutter version constraint the same as the Flutter version you use. Try to set an upper bound on flutter in a package's pubspec.yaml and after running flutter pub publish --dry-run you'll see:

Package validation found the following potential issue:
* The Flutter constraint should not have an upper bound.
  In your pubspec.yaml the constraint is currently `>=3.3.0 <4.0.0`.

  You can replace that with just the lower bound: `>=3.3.0`.

  See https://dart.dev/go/flutter-upper-bound-deprecation

So for using current stable version of Flutter, it'd be:

environment:
  sdk: '>=2.19.4 <4.0.0'
  flutter: '>=3.7.7'

At work, when we upgrade a project to a newer Flutter version, we also update lower bound of flutter in pubspec.yaml, and I think it's a good practice.

Repository owner locked and limited conversation to collaborators Mar 21, 2023
@subosito subosito converted this issue into discussion #215 Mar 21, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants