Flutter force higher package dependency version

1,473

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
Share:
1,473
kosiara - Bartosz Kosarzycki
Author by

kosiara - Bartosz Kosarzycki

I'm a senior Java/Android developer constantly developing his skills more here: https://sites.google.com/site/bkosarzyckiaboutme/

Updated on December 16, 2022

Comments

  • kosiara - Bartosz Kosarzycki
    kosiara - Bartosz Kosarzycki over 1 year

    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?