Search code examples
flutterdartflutter-dependenciesdart-pub

How to disable Flutter sound-safety and null-safety for the SplashScreen library?


I am trying to run the SplashScreen library but it isn't working. I have edited the package’s pubspec.yaml file, setting the minimum SDK constraint to 2.7.0, It brought out this error:

lib/mySplashScreen.dart:5:28: Error: Null safety features are disabled for this library. Try removing the package language version or setting the language version to 2.12 or higher. const MySplashScreen({Key? key}) : super(key: key); ^ Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

I added a language version comment to the top of the Dart files, ie: // @dart=2.9 It brought this error:

Error: A library can't opt out of null safety by default, when using sound null safety. // @dart=2.9 ^^^^^^^^^^^^

What do I do?


Solution

  • If you want you can just disable null safety, without downgrading.

    Add this to your launch configuration:

    --no-sound-null-safety
    

    More info on https://dart.dev/null-safety/unsound-null-safety