close

[Solved] Error: Null safety features are disabled for this library

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: Null safety features are disabled for this library 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: Null safety features are disabled for this library Error Occurs ?

When I am trying to run my app Its give me following error.

Users/ssc/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:100:4: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
Uri? _currentUriBase;
   ^
/Users/ssc/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:106:7: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
String? _current;

How to Solve Error: Null safety features are disabled for this library Error?

  1. How to Solve Error: Null safety features are disabled for this library Error?

    To Solve Error: Null safety features are disabled for this library Error you just need to upgrade your flutter version. Because minimum required version for enabling null safety is at least 2.12. To solve this error just follow the below step. Open your terminal at the root level of your project. run flutter upgrade. Change SDK version in pubspec.yaml file In my pubspec.yaml I just changed This line sdk: “>=2.7.0 <3.0.0” and replaced with sdk: “>=2.12.0 <3.0.0” flutter clean flutter run.

  2. Error: Null safety features are disabled for this library

    To Solve Error: Null safety features are disabled for this library Error you just need to upgrade your flutter version. Because minimum required version for enabling null safety is at least 2.12. To solve this error just follow the below step. Open your terminal at the root level of your project. run flutter upgrade. Change SDK version in pubspec.yaml file In my pubspec.yaml I just changed This line sdk: “>=2.7.0 <3.0.0” and replaced with sdk: “>=2.12.0 <3.0.0” flutter clean flutter run.

Solution 1 : flutter upgrade

To solve this issue you just need to upgrade your flutter version. Because minimum required version for enabling null safety is at least 2.12. To solve this error just follow below step.

  1. Open your terminal in root level of your project.
  2. run flutter upgrade.
  3. Change SDK version in pubspec.yaml file
  4. In my pubspec.yaml I just changed This line sdk: “>=2.7.0 <3.0.0” and replaced with sdk: “>=2.12.0 <3.0.0”
  5. flutter clean
  6. flutter run.

Solution 2: Change SDK version in pubspec.yaml

Just change SDK version and added below line was solved my problem.

  1. Add below line to your pubspec.yaml
analyzer:
  enable-experiment:
  - non-nullable
  1. Upgrade your SDK in pubspec.yaml
environment:
  sdk: ">=2.13.0-68.0.dev <3.0.0"

This works for me…!!!!

Solution 3: Try this code

It’s working fine for me

version: 1.0.0+1
analyzer:
  enable-experiment:
    - non-nullable
environment:
  sdk: ">=2.11.0-213.1.beta <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

%d bloggers like this: