Flutter "Cannot run with sound null safety" in CI
A dependency in the project has not been migrated to null safety, but the build runs in sound null-safety mode, so it refuses to run.
What this error means
The build or run fails with Cannot run with sound null safety, because the following dependencies don't support null safety, listing the offending packages.
flutter
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:legacy_pkgCommon causes
A dependency predates null safety
An old package was never migrated, so it is incompatible with sound null safety.
Pinned to an outdated version
A newer null-safe release exists but the project pins an older one.
How to fix it
Upgrade the dependency to a null-safe version
- Find a null-safe release of the package and update pubspec.yaml.
- Run flutter pub get and rebuild.
shell
flutter pub upgrade legacy_pkg
flutter pub getReplace or fork an unmaintained package
If no null-safe release exists, switch to a maintained alternative rather than disabling null safety.
How to prevent it
- Keep dependencies on null-safe versions and avoid abandoned packages. Resolve and commit pubspec.lock so the dependency set is reproducible.
Related guides
Flutter "version solving failed" in CIFix the Flutter "version solving failed" error in CI by aligning package and SDK constraints in pubspec so a…
Flutter "command not found / not on PATH" in CIFix the Flutter "command not found" / not-on-PATH error in CI by installing the Flutter SDK and adding its bi…
Flutter "Gradle task assembleRelease failed" in CIFix the Flutter "Gradle task assembleRelease failed with exit code 1" error in CI by reading the underlying G…