'Null safety migration error: package has unmigrated dependencies. But all my dependencies declare support for null-safety

Im trying to migrate dart null safety but I get the following error when I run dart migrate

Bad state: Error: package has unmigrated dependencies.

Before migrating your package, we recommend ensuring that every library it
imports (either directly or indirectly) has been migrated to null safety, so
that you will be able to run your unit tests in sound null checking mode.  You
are currently importing the following non-null-safe libraries:

  file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/basic_project.dart
  file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/deferred_components_config.dart
  file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/project.dart
  file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_driver.dart
  file:///C:/flutter/packages/flutter_tools/test/src/test_flutter_command_runner.dart
  file:///C:/flutter/packages/flutter_tools/test/src/testbed.dart
 package:dwds/data/build_result.dart
  package:dwds/data/connect_request.dart
  package:dwds/data/debug_event.dart
  package:dwds/data/devtools_request.dart
  package:dwds/data/error_response.dart
  package:dwds/data/extension_request.dart
  package:dwds/data/isolate_events.dart
  package:dwds/data/register_event.dart
  package:dwds/src/debugging/dart_scope.dart
  package:dwds/src/debugging/debugger.dart
  package:dwds/src/debugging/execution_context.dart
  package:dwds/src/debugging/frame_computer.dart
  package:dwds/src/debugging/inspector.dart
  package:dwds/src/debugging/instance.dart
  package:dwds/src/debugging/libraries.dart
  package:dwds/src/debugging/location.dart
  package:dwds/src/debugging/metadata/class.dart
  package:dwds/src/debugging/metadata/function.dart
  package:dwds/src/debugging/metadata/module_metadata.dart
  package:dwds/src/debugging/metadata/provider.dart



Please upgrade the packages containing these libraries to null safe versions
before continuing.  To see what null safe package versions are available, run
the following command: `dart pub outdated --mode=null-safety`.

When I run dart pub outdated --mode=null-safety I got this message and everything seems to be ready for null safety:

C:\flutter\packages\flutter_tools>flutter pub outdated --mode=null-safety
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
[✓] indicates versions opting in to null safety.

All your dependencies declare support for null-safety.

How can I upgrade these packages and migrate to null safety? Appreciate every answer :)



Solution 1:[1]

You can use migration helper tool with this command line:

dart migrate

Or you can migrate manually after change min flutter sdk version in pubspec.yaml

environment:
  sdk: '>=2.12.0 <3.0.0'

and after this change you need launch this command:

flutter pub get

Solution 2:[2]

The tool is listing the following files as non-null-safe:

file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/basic_project.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/deferred_components_config.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_data/project.dart
file:///C:/flutter/packages/flutter_tools/test/integration.shard/test_driver.dart
file:///C:/flutter/packages/flutter_tools/test/src/test_flutter_command_runner.dart
file:///C:/flutter/packages/flutter_tools/test/src/testbed.dart

They belong to Flutter itself: https://github.com/flutter/flutter/tree/master/packages/flutter_tools/test

So you should update Flutter itself. You can do this in pubspec.yaml:

environment:
  sdk: ">=2.15.0 <3.0.0"
  flutter: ">=2.10.0"       # <= here

I am not sure which version got those files migrated, so try the most recent one that does not break your code too much.

Solution 3:[3]

That is because you need update your packages, some packages don't have support for null safety , then you need to check each one of your packages , for example.. you can looking some package and on the top say if the package have or not have support for null safety (for example the image ), (sometimes users update in other repositories then check on the issues page from GitHub *if the package don't have support) enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thetyne
Solution 2 Alexey Inkin
Solution 3 Victor Lagunas