I'm integrating Interstitial ads in my flutter project. But When I declare like this

 InterstitialAd? _interstitialAd; 

I am getting this error:

33:17: 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.   InterstitialAd? _interstitialAd;                 ^ lib/admob_service.dart:64:20: 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.     _interstitialAd!.fullScreenContentCallback = FullScreenContentCallback(                    ^ lib/admob_service.dart:79:20: 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.     _interstitialAd!.show(); 

I saw some stackoverflow answers and tried to upgrade the sdk version from

environment:   sdk: ">=2.7.0 <3.0.0" 

to

environment:   sdk: ">=2.12.0 <3.0.0" 

Then I got errors in my whole project.The error message is :

Error: Cannot run with sound null safety, because the following dependencies don't support null safety:  - package:local_database  - package:auto_size_text  - package:queue

Is there any way other than declaring this : InterstitialAd? _interstitialAd;

Tag:google-ads-api, flutter, dart, flutter-layout, flutter-dependencies

Only one comment.

  1. esentis

    Seems like the packages you mentioned, haven't been migrated to null safety hence the error.

    The only workaround here is you update the packages to their null-safety version (if any) OR just don't use sound null safety for your project.

Add a new comment.