"flutter run" gives me a lot of errors while everything works perfect using "flutter run --no-sound-null-safety"

Viewed 46

I have been making this app for a while now, and I have always used flutter run --no-sound-null-safety to run the app. Everything went well. But now I try to run the project with the command flutter run and I get a lot of errors. Errors I wouldn't have gotten when using flutter run --no-sound-null-safety.

When using flutter run

Think of errors like type type 'Null' is not a subtype of type 'bool'or The relevant error-causing widget was: Consumer<ConnectivityProvider> and Unhandled Exception: type 'Null' is not a subtype of type 'int'.

Even when I made no changes in the code. How is this possible and what should I do to fix these errors?

1 Answers

You get these errors because your code is not sound null safe. If you for example initialize

bool x = null; 

you will get an error because null safety tries to avoid errors related to variables that are not initialized. This can help you to make your code null safe.

Related