Encountering errors while working on a Flutter project can be frustrating. One common issue is the “Requires SDK version >=2.18.6 <3.0.0” error, which indicates a version compatibility problem with the SDK.
In this guide, we will walk through the steps to fix this error without modifying your project’s source files or updating Dart and Flutter versions.
Because it requires SDK version >=2.18.6 <3.0.0, version solving failed.
pub get failed (1; Because requires SDK version >=2.18.6 <3.0.0, version solving failed.)
Table of Contents
Steps to Fix Requires SDK version >=2.18.6 <3.0.0
If you found this type of issue in your project, there is no need to change anything in the project source files or update the Dart and Flutter versions; simply follow these steps:
- Launch your pubspec.yaml file.
- SDK version search
- Replace your current SDK version with the required SDK version.
Try like this:
Check Out: [Solved] Unable to load asset: images in Flutter
Step 1: Open pubspec.yaml
Locate and open the pubspec.yaml file in your Flutter project. This file contains the project’s dependencies and configuration.
Step 2: Search for SDK Version
Within the pubspec.yaml file, search for the line that specifies the SDK version for your project. It usually looks like this:
From:
environment:
sdk: '>=2.18.0 <3.0.0'
Step 3: Update the SDK Version
Replace the existing SDK version range with the required SDK version mentioned in the error message. In this case, it should be ‘>=2.18.6 <3.0.0’. Modify the line as follows:
To:
environment:
sdk: '>=2.18.6 <3.0.0'
Step 4: Save Changes
Save the changes made to the pubspec.yaml file.
Step 5: Get Dependencies
To ensure the changes take effect, you need to fetch the updated dependencies. There are two ways to do this:
 environment:
 sdk: '>=2.18.0 <3.0.0'
Conclusion
By following these steps, you can resolve the “Requires SDK version >=2.18.6 <3.0.0” error in your Flutter project without making any changes to your source files or updating Dart and Flutter versions.
Remember to always check for specific version requirements and update the SDK version accordingly in your pubspec.yaml file. After updating, run flutter pub get to fetch the updated dependencies.