Flutter force higher package dependency version

左心房为你撑大大i 提交于 2020-01-25 06:46:05

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/59515430/flutter-force-higher-package-dependency-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!