Introduction
When running flutter pub get, you may encounter a platform conflict error where a dependency declares a constraint that is incompatible with your target platform. This commonly happens when a package supports only certain platforms, or when transitive dependencies pull in platform-specific versions that conflict with your project's SDK constraints. The error is particularly common in multi-platform projects (mobile + web + desktop) where a newly updated package drops support for one platform, or when a dependency adds a platform-specific native requirement that your project cannot satisfy.
Symptoms
flutter pub getfails with error:`- Because my_app depends on package_a ^2.0.0 which doesn't support any version, version solving failed.
`- Or more specifically:
`- Because package_b 3.1.0 doesn't support android and my_app depends on package_b ^3.0.0, version solving failed.
`- The error mentions specific platforms (android, ios, web, linux, macos, windows)
- Running
flutter doctorshows all toolchains are healthy, confirming the issue is dependency-level
Common Causes
- A direct dependency dropped support for a platform you are targeting
- A transitive dependency pulled in by another package has platform constraints
- Your
pubspec.yamlSDK constraint is too broad for the packages you depend on - A conditional import in a package's
pubspec.yamlusesplatforms:key incorrectly
Step-by-Step Fix
- 1.Identify the conflicting dependency:
- 2.```bash
- 3.flutter pub deps --style=compact
- 4.
` - 5.This shows the full dependency tree. Look for the package mentioned in the error.
- 6.Check which version supports your platform:
- 7.```bash
- 8.flutter pub outdated
- 9.
` - 10.This shows available versions and which platforms they support.
- 11.Use dependency overrides as a temporary fix:
- 12.```yaml
- 13.# pubspec.yaml
- 14.dependency_overrides:
- 15.conflicting_package:
- 16.git:
- 17.url: https://github.com/maintainer/conflicting_package.git
- 18.ref: main
- 19.
` - 20.Pin to a compatible version:
- 21.```yaml
- 22.dependencies:
- 23.problematic_pkg: ^2.4.0 # Last version supporting your platform
- 24.
` - 25.If using Flutter 3.16+, check conditional imports:
- 26.```yaml
- 27.# Some packages use this format:
- 28.platforms:
- 29.android:
- 30.package: com.example.pkg
- 31.pluginClass: ExamplePlugin
- 32.ios:
- 33.pluginClass: ExamplePlugin
- 34.# If 'web' is missing, the package does not support web
- 35.
` - 36.Clean and retry:
- 37.```bash
- 38.flutter clean
- 39.flutter pub cache clean
- 40.flutter pub get
- 41.
`
Prevention
- Regularly run
flutter pub outdatedto catch platform support changes early - Pin dependency versions in production rather than using caret ranges
- Check package health on pub.dev before adding dependencies, looking at the "Platforms" badge
- Use
flutter pub deps --jsonin CI to detect platform constraint changes before merging - Maintain a multi-platform test matrix that runs
flutter pub geton each target platform - Consider using
dependency_overridesonly as a short-term workaround, not a permanent solution - Review the pub.dev package changelog before upgrading to understand platform support changes