I have the following pubspec.yaml
file.
environment:
sdk: '>=3.1.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
When I run the update command to change the dependencies, I get the following error:
The current Dart SDK version is 3.1.0.
Because mi_card depends on cupertino_icons >=0.1.1 <1.0.1 which
doesn’t support null safety, version solving failed.The lower bound of "sdk: ‘<2.0.0 or >=2.0.0-dev.28.0 <3.0.0’" must be
2.12.0 or higher to enable null safety. For details, see https://dart.dev/null-safetyYou can try the following suggestion to make the pubspec resolve:
- Try upgrading your constraint on cupertino_icons: flutter pub add cupertino_icons:^1.0.6
I was expecting to update the dependencies, but it didn’t work.
2
Answers
Welcome to Stack Overflow, @Bheem!
It seems that you are using an old version of the
cupertino_icons
package which does not support null safety.One step upgrade
The easiest way to solve this issue is to upgrade your package dependencies to the latest version.
Or
Two step upgrade
Alternatively, you can upgrade one package by removing the package and then adding it back. Execute the following commands in your terminal.
It will remove the
cupertino_icons
package. Look at thepubspec.yaml
file, and you will see no Cupertino package. To add back the package, run this command:Make sure that the Cupertino package is added to the
pubspec.yaml
file.What worked for me was manually editing the cupertino_icons field to ^1.0.6 in my pubspec.yaml file, and then running “Get Dependencies” in my main.dart file.