Search code examples
flutterdarthttptwitterinstagram-api

How Can I Use Different Versions of the Same Package at the Same Time?


Problem

I'm trying to use dart_twitter_api, youtube_api and instagram_media in my project.

Each of these require http package but version are different.

So when I try to install instagram_media, an error occurs.

Because dart_twitter_api >=0.4.0 depends on http ^0.13.0 and every version of instagram_media depends on http ^0.12.0, dart_twitter_api >=0.4.0 is incompatible with instagram_media.

So, because MyProject depends on both dart_twitter_api ^0.5.6+1 and instagram_media any, version solving failed. pub finished with exit code 65

Pubspec.yaml

My pubspec.yaml is below.

dependencies:
  flutter:
    sdk: flutter


  dart_twitter_api: ^0.5.6+1
  youtube_api: ^1.0.4

  http: any

  # ..... other pubs

Required http versions

Package Required http version
dart_twitter_api >=0.4.0 ^0.13.0
youtube_api 1.0.4 ^0.13.3
instagram_media >= any ^0.12.0

Strange thing is that dart_twitter_api and youtube_api can live together, and only when I do flutter pub add instagram_media, this error occurs.

What I Want to Do

As I said earlier,I want to use dart_twitter_api, youtube_api and instagram_media in one project.

How can I use http ^0.13.3 and http ^0.12.0 at the same time?

Like below;

dependencies:
  flutter:
    sdk: flutter

  http: ^0.13.3
  http: ^0.12.0

Solution

  • By editing pubspec.yaml like;

    dependency_overrides:
      http: ^0.13.4
    

    I could implement instagram_media to my project.