Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 946
yolo Avatar asked Nov 02 '25 03:11

yolo


1 Answers

By editing pubspec.yaml like;

dependency_overrides:
  http: ^0.13.4

I could implement instagram_media to my project.

like image 173
yolo Avatar answered Nov 04 '25 19:11

yolo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!