skip to Main Content

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-safety

You 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


  1. 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.

    flutter pub upgrade --major-versions
    

    Or

    flutter pub add cupertino_icons:^1.0.6
    

    Note: If you do not know the available version, ask for version suggestion for a single package with the flutter pub upgrade cupertino_icons command. It will recommend you to another upgrade command with version specification.

    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.

    flutter pub remove cupertino_icons
    

    It will remove the cupertino_icons package. Look at the pubspec.yaml file, and you will see no Cupertino package. To add back the package, run this command:

    flutter pub add cupertino_icons
    

    Make sure that the Cupertino package is added to the pubspec.yaml file.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search