Due to the coming of new NULL safety in a Dart, everyone is facing this error Cannot run with sound null safety because dependencies don’t support null safety while running a new app or existing app.
The solution is simple just need to Add one line if you run the app from the command line or terminal.
After flutter run add –no-sound-null-safety.
flutter run --no-sound-null-safety
Another automated way to add this line to IDE
There is one more method to add a value to confirmation so that every time we run it should auto pick that line from the configuration.
Step 1
Click on the box where it says main.dart. This is the box where we select and tell the IDE to first run this file when we click on the run button.
Step 2
Now, Click on Edit Configuration to open up Run/Debug Configuration. In this section, the user should add default running/debugging commend.
Step 3
When this RUN/DEBUG configuration opens up you can see an attribute that says – Additional run args: this attribute will let us add additional commands while running the app. Follow the steps as shown in the image below. Paste the line –no-sound-null-safety and hit ok.
flutter run --no-sound-null-safety
When you opt into null safety, types in your code are non-nullable by default, meaning that variables can’t contain null
unless you say they can. With null safety, your runtime null-dereference errors turn into edit-time analysis errors.
For more Flutter tutorials, Tips, Tricks, Free code, Questions, and Error Solving.
Remember FlutterDecoder.com