JabidHasan
JabidHasan

Reputation: 11

Cannot build dart project due to custom dependencies doesn't support sound null safety

I have been studying over dart projects and tesing dart packages and interdependencies. I created a Dart Project called console_full_project, where within the project i made a package called calculator and added it to main projects pubspec.yaml file.

main project's pubspec.yaml codes are

name: console_full_project
description: A sample command-line application.
version: 1.0.0

publish_to: none

# homepage: https://www.example.com

environment:
  sdk: ">=2.17.0-266.8.beta <3.0.0"

dependencies:
  calculator:
    path: "packages/calculator"

dev_dependencies:
  lints: ^2.0.0
  test: ^1.16.0

and my packages pubspec.yaml file's codes are

name: calculator

environment:
  sdk: ">=2.10.0<3.0.0"

dependencies:
  lints: ^2.0.0

While a tried dart run command in my terminal

It resulted

Failed to build console_full_project:console_full_project: Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

For solutions, see https://dart.dev/go/unsound-null-safety

Upvotes: 0

Views: 112

Answers (1)

Usama Karim
Usama Karim

Reputation: 1428

There are many solutions to this problem.

  1. Decrease project level environment variable in pubspec.yaml file to 2.10.0
environment:
  sdk: ">=2.10.0 <3.0.0"
  1. Try to run the project with the following command in project level directory
flutter run --no-sound-null-safety

Note: The following options might not be available if the package is out of your control.

  1. (Optional) Increase package level environment variable in pubspec.yaml file to 2.12.0 or above
environment:
  sdk: ">=2.12.0 <3.0.0"
  1. (Optional) Use dart migration tool in your package level directory with dart migrate command

Upvotes: 1

Related Questions