Version solving failing on running "flutter pub get" for Riverpod with the new Flutter 2.2.2 verison

613

Solution 1

When using riverpod, you only need to include one dependency.

It appears you are including riverpod and flutter_riverpod.

Instead, use just flutter_riverpod.

To make this very clear:

valid pubspec.yaml for:

pure-dart:

dependencies:
  riverpod: ^0.14.0

non-hooks:

dependencies:
  flutter_riverpod: ^0.14.0

hooks:

dependencies:
  hooks_riverpod: ^0.14.0

This information can be viewed via a flowchart in the docs.

Edit: Your specific problem is because your project is named riverpod. It is conflicting with the riverpod dependency of hooks_riverpod and flutter_riverpod. Rename your project and it will work.

Solution 2

Okay i am new to this riverpod side now non of this answers worked for me until i remember that i have already installed riverpod by mistake(pure-dart) then i have removed that dependency from pubs.yml and added flutter-riverpod and after that it was same error

Because riverpod depends on flutter_riverpod ^0.14.0+3 which depends on riverpod ^0.14.0+3, riverpod ^0.14.0+3 is required

now since this is just learning project i was able to create a new app and then install flutter_riverpod: ^0.14.0+3 then it was working without any problems.

if there are any one who's facing same issue try flutter clean and then run the application again without debugging then hopefully everything will work or if your still learning like me just create a new application

I think even though we removed dependency from pubs.yml there is still some record over there so that confusing package installer

Solution 3

I got this problem. This caused because I put name: riverpod in my pubspec.yaml file. I can see you also did the same mistake. Change the name and try. Hope you save time.

Share:
613
Varun Jain
Author by

Varun Jain

Updated on December 19, 2022

Comments

  • Varun Jain
    Varun Jain over 1 year

    I have tried replacing the version of riverpod with the previous versions but nothing worked. I have also tried deleting the pubspec.lock file, running flutter clean command, etc but nothing worked. If anyone who is using flutter 2.2.2 is able to use riverpod(any version), then please help.

    pubspec.yaml file:

    name: riverpod
    description: A new Flutter project.
    
    # The following line prevents the package from being accidentally published to
    # pub.dev using `pub publish`. This is preferred for private packages.
    publish_to: 'none' # Remove this line if you wish to publish to pub.dev
    
    # The following defines the version and build number for your application.
    # A version number is three numbers separated by dots, like 1.2.43
    # followed by an optional build number separated by a +.
    # Both the version and the builder number may be overridden in flutter
    # build by specifying --build-name and --build-number, respectively.
    # In Android, build-name is used as versionName while build-number used as versionCode.
    # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
    # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
    # Read more about iOS versioning at
    # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.12.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
      cupertino_icons: ^1.0.2
      flutter_riverpod: ^0.14.0+3
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
    # For information on the generic Dart part of this file, see the
    # following page: https://dart.dev/tools/pub/pubspec
    # The following section is specific to Flutter.
    flutter:
    
      # The following line ensures that the Material Icons font is
      # included with your application, so that you can use the icons in
      # the material Icons class.
      uses-material-design: true
      # To add assets to your application, add an assets section, like this:
      # assets:
      #   - images/a_dot_burr.jpeg
      #   - images/a_dot_ham.jpeg
      # An image asset can refer to one or more resolution-specific "variants", see
      # https://flutter.dev/assets-and-images/#resolution-aware.
      # For details regarding adding assets from package dependencies, see
      # https://flutter.dev/assets-and-images/#from-packages
      # To add custom fonts to your application, add a fonts section here,
      # in this "flutter" section. Each entry in this list should have a
      # "family" key with the font family name, and a "fonts" key with a
      # list giving the asset and other descriptors for the font. For
      # example:
      # fonts:
      #   - family: Schyler
      #     fonts:
      #       - asset: fonts/Schyler-Regular.ttf
      #       - asset: fonts/Schyler-Italic.ttf
      #         style: italic
      #   - family: Trajan Pro
      #     fonts:
      #       - asset: fonts/TrajanPro.ttf
      #       - asset: fonts/TrajanPro_Bold.ttf
      #         weight: 700
      #
      # For details regarding fonts from package dependencies,
      # see https://flutter.dev/custom-fonts/#from-packages
    

    I am attaching the output below:

    Running "flutter pub get" in riverpod...                        
    Because riverpod depends on flutter_riverpod ^0.14.0+3 which depends on riverpod ^0.14.0+3, riverpod ^0.14.0+3 is required.
    So, because riverpod is 1.0.0+1, version solving failed.
    
    pub get failed (1; So, because riverpod is 1.0.0+1, version solving failed.)
    exit code 1```
    
    • msbit
      msbit almost 3 years
      Your project is called riverpod, which has a dependency on flutter_riverpod, which itself has a dependency on riverpod (the published one). As you can imagine, that's confusing the resolver. You need to change the name of your project.
  • Varun Jain
    Varun Jain almost 3 years
    I am using just one dependency "flutter_riverpod" but then too, the issue presists.
  • Alex Hartford
    Alex Hartford almost 3 years
    Updated my answer.
  • Varun Jain
    Varun Jain almost 3 years
    Thank you very much. was such a silly mistake...slipped from my mind 😅
  • Varun Jain
    Varun Jain almost 3 years
    yes, you are right. I had this same problem. Sorted now :)