Hello guys, First of all sorry for being so inactive on site, I was busy with some of my company stuff. Now I’m back with an Error solution tutorial in flutter. Today when I was trying to install a Vibration package from PUB.DEV then I saw a error “Error: Cannot run with sound null safety, because the following dependencies don’t support null safety.” After searching a lot on internet and reading some docs provided from flutter I fount its permanent solution. So let’s get started 🙂 .
Complete Error :-
D:\Flutter\app>flutter run
Launching lib\main.dart on M2007J20CI in debug mode…
Error: Cannot run with sound null safety, because the following dependencies
don’t support null safety:
– package:vibration
For solutions, see https://dart.dev/go/unsound-null-safety
FAILURE: Build failed with an exception.
* Where:
Script ‘E:\Android_SDK\flutter_sdk\packages\flutter_tools\gradle\flutter.gradle’ line: 1035
* What went wrong:
Execution failed for task ‘:app:compileFlutterBuildDebug’.
> Process ‘command ‘E:\Android_SDK\flutter_sdk\bin\flutter.bat” finished with non-zero exit value 1
* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 28s
Running Gradle task ‘assembleDebug’…
Running Gradle task ‘assembleDebug’… Done 29.4s
Exception: Gradle task assembleDebug failed with exit code 1
Solution for Flutter Error Solution Cannot run with sound null safety, because the following dependencies :-
1. To solve this error all you have to do is add below line in your flutter project’s main.dart file at the top or you can say in the first line of your code as Comment.
1 |
// @dart=2.9 |
2. Now run your project and you’ll see the error is gone. You can read flutter Unsound null safety documentation here for brief information.