问题
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