[Solved] Error: This requires the ‘non-nullable’ experiment to be enabled

Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. Error: This requires the ‘non-nullable’ experiment to be enabled in a flutter. So today Here I come with all possible solutions for this error.

We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.

How Error: This requires the ‘non-nullable’ experiment to be enabled Occurs ?

I am using analyzer with non-nullable types and added this to my analysis_options.yaml

analyzer:
  enable-experiment:
    - non-nullable

Now I am trying to build in iOS by following command line.

flutter build ios

I get the error message:

 lib/main.dart:61:26: Error: This requires the 'non-nullable' experiment to be enabled.

    Try enabling this experiment by adding it to the command line when compiling and running.

How to Solve Error: This requires the ‘non-nullable’ experiment to be enabled?

  1. How to Solve Error: This requires the 'non-nullable' experiment to be enabled?

    To Solve Error: This requires the 'non-nullable' experiment to be enabled you just need to cleaning and upgrading the project dependencies again. Run the below command one by one. The second solution is Many times it's as simple as changing the environment in your pubspec.yaml file to update the lower end and For null safety to work, should be this version at least. then run flutter clean and pub get it will work.

  2. Error: This requires the 'non-nullable' experiment to be enabled

    To Solve Error: This requires the 'non-nullable' experiment to be enabled you just need to cleaning and upgrading the project dependencies again. Run the below command one by one. The second solution is Many times it's as simple as changing the environment in your pubspec.yaml file to update the lower end and For null safety to work, should be this version at least. then run flutter clean and pub get it will work.

Solution 1: cleaning and upgrading the project dependencies again

Actually, this problem occurs just after upgrading the Flutter. To solve this error you just need to cleaning and upgrading the project dependencies again. Run the below command one by one.

First of all clean project by running:

flutter clean

Then upgrading the project dependencies:

flutter packages pub upgrade

Then just run,

flutter pub run build_runner build

Solution 2: changing the environment

Manytime it’s as simple as changing the environment in your pubspec.yaml file to update the lower end and For null safety to work, should be this version at least. then run flutter clean and pub get it will work.

environment:
   sdk: ">=2.12.0 <3.0.0"

Or

environment:
sdk: ">=2.6.0 <3.0.0"

Or

environment:
sdk: ">=2.7.0 <3.0.0"

Summery

So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below on which solution worked for you. Thank You.

Also Check Out Below Tutorials

Leave a Comment

  Canva Pro Crack Filmora Pro Crack Spotify Premium Free Download Tradingview Premium Free