Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter force higher package dependency version

TLDR: How to force a specific Flutter package (library) version for the entire app?

Let's suppose I have the following dependencies in my pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter

  datetime_picker_formfield: 0.4.3
  date_utils: 0.1.0+3
  intl: 0.15.8

which gives me a version conflict error:

Because flutter_app depends on date_utils 0.1.0+3 
which depends on intl ^0.16.0, intl ^0.16.0 is required.

but when we change intl to intl: 0.15.8 we get:

Because flutter_app depends on datetime_picker_formfield 0.4.3 
which depends on intl ^0.15.8, intl ^0.15.8 is required.

How to force intl: 0.16.0 for both: datetime_picker_formfield and date_utils packages?

like image 801
kosiara - Bartosz Kosarzycki Avatar asked Jul 17 '26 04:07

kosiara - Bartosz Kosarzycki


1 Answers

Use dependency_overrides to force a specific package version for the entire Flutter app.

dependency_overrides:
  intl: 0.16.0

So we get:

dependencies:
  flutter:
    sdk: flutter

  datetime_picker_formfield: 0.4.3
  date_utils: 0.1.0+3
  intl: 0.16.0
  cupertino_icons: ^0.1.2

dependency_overrides:
  intl: 0.16.0
like image 89
kosiara - Bartosz Kosarzycki Avatar answered Jul 18 '26 17:07

kosiara - Bartosz Kosarzycki



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!