I have followed "Enabling null safety" on dart.dev
and also migrated my whole Flutter application to null safety.
Now, I am trying to run it using flutter run
. However, it will not start because of the following error:
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:cloud_firestore_web
- package:firebase_core_web
- package:shared_preferences
- package:url_launcher_web
- package:firebase_auth
- package:http
- package:provider
...
For solutions, see https://dart.dev/go/unsound-null-safety
Failed to compile application.
The guide at the URL says that I should "wait for dependencies to migrate before you migrate your package", but I want to use non-nullable by default (NNBD) now.
How can I do that?
First, you should read through the guide to understand unsound null safety. If you are sure that you want to run your application with unsound null safety, you can use the following command:
flutter run --no-sound-null-safety
The --no-sound-null-safety
option is not documented in the article, however, I have not experienced any problems with it for the last few months (and especially not since the whole Flutter framework has been migrated to null safety).
The documentation has now been updated to include this. See Testing or running mixed-version programs.
To set this up in your IDE of choice, you can use:
In both cases, add --no-sound-null-safety
.
For tests, you will want to do the same thing:
In both cases, add --no-sound-null-safety
.