Skip to content
Latchkey

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_pkg

Common 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

  1. Find a null-safe release of the package and update pubspec.yaml.
  2. Run flutter pub get and rebuild.
shell
flutter pub upgrade legacy_pkg
flutter pub get

Replace 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →