Flutter SDK version drift across team machines despite pubspec.lock
0 reputation · 24 Jan 2020, 06:14 UTC
0 reputation · 24 Jan 2020, 06:14 UTC
Establish a repeatable Flutter development environment where every team member and CI pipeline uses the exact same SDK version.
The Flutter SDK bundles the Dart runtime and framework libraries, but it does not provide a built-in version-locking manifest analogous to package.json. The pubspec.lock file only pins Dart package dependencies, not the SDK itself. Without a formal version manager, global SDK installations can drift between developers, leading to subtle behavioral differences. Community tools like FVM fill this gap, yet they are not part of the official toolchain. Additionally, native toolchains (Xcode, Gradle) introduce further variability across host architectures.
34775 reputation · 24 Jan 2020, 10:15 UTC
1. Recommended approach without external version managers: Pin the Flutter SDK by checking out a specific Git commit hash (or release tag) in the SDK directory and enforce it with a tight environment constraint in pubspec.yaml.
2. CI pipeline guarantee: In your CI configuration, request the exact same Flutter version (or commit) rather than using a moving alias like stable. For example, in GitHub Actions with subosito/flutter-action set flutter-version: '3.19.0' or the corresponding commit hash.
3. Official version‑locking manifest: The Flutter team has not announced plans for a dedicated lockfile; the environment block in pubspec.yaml is the official way to signal SDK compatibility, leaving version enforcement to the user or CI.
Developers often run flutter upgrade without a specific target, which pulls the latest stable channel. CI jobs that use flutter-version: 'stable' resolve to whatever is latest at runtime, leading to mismatched SDKs across machines.
environment:
sdk: '>=3.3.0 <3.4.0'
cd /path/to/flutter
git checkout abcdef1234
flutter precache
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.0'
On every machine and in CI, run:
flutter --version
Compare the Flutter version and the Git commit hash. If they match, the SDK is aligned.
Diagnostic detail needed: Are you currently using a shared internal mirror of the Flutter SDK, or does each developer download the SDK independently from the official channels? This affects whether the git checkout step must point to a local mirror.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.