I’m new on Flutter and i’m having some doubt about how i’m managing dependencies.
Here’s my current dependencies on the pubspec.yml:
environment:
sdk: '>=3.4.1 <4.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
english_words: ^4.0.0
supabase_flutter: ^2.5.8
intl: ^0.19.0
collection: ^1.18.0
flutter_svg: ^2.0.10+1
timezone: ^0.9.4
modal_bottom_sheet: ^3.0.0
excel: ^4.0.3
file_picker: ^8.0.6
universal_io: ^2.2.2
flutter_launcher_icons: "^0.13.1"
url_launcher: ^6.3.0
envied: ^0.5.4+1
envied_generator: ^0.5.4+1
build_runner: ^2.4.11
version: ^3.0.2
package_info_plus: ^8.0.0
http: ^1.2.1
on pub get i have the following output:
Resolving dependencies...
Downloading packages...
_fe_analyzer_shared 67.0.0 (73.0.0 available)
analyzer 6.4.1 (6.8.0 available)
archive 3.4.9 (3.6.1 available)
collection 1.18.0 (1.19.0 available)
http_parser 4.0.2 (4.1.0 available)
leak_tracker 10.0.4 (10.0.5 available)
leak_tracker_flutter_testing 3.0.3 (3.0.5 available)
material_color_utilities 0.8.0 (0.12.0 available)
meta 1.12.0 (1.15.0 available)
rxdart 0.27.7 (0.28.0 available)
shelf 1.4.1 (1.4.2 available)
string_scanner 1.2.0 (1.3.0 available)
test_api 0.7.0 (0.7.3 available)
web 0.5.1 (1.0.0 available)
web_socket_channel 2.4.5 (3.0.1 available)
Got dependencies!
15 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
exit code 0
And i can’t upgrade collection to version ^1.19.0 because i get this error:
Resolving dependencies...
Note: collection is pinned to version 1.18.0 by flutter_test from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.
Because every version of flutter_test from sdk depends on collection 1.18.0 and *** depends on collection ^1.19.0, flutter_test from sdk is forbidden.
So, because *** depends on flutter_test from sdk, version solving failed.
You can try the following suggestion to make the pubspec resolve:
* Consider downgrading your constraint on collection: flutter pub add collection:^1.18.0
What can i do to solve somehow this situation? What am i missing?
Thanks in advance!!
2
This behavior is currently (July 2024) as expected.
Yes, I know it’s annoying. It seems for the longest time, Flutter has pinned collection
to one minor revision below the latest, resulting in output like this from flutter pub outdated
:
Package Name Current Upgradable Resolvable Latest
direct dependencies:
collection *1.18.0 *1.18.0 *1.18.0 1.19.0
But clearly, that output says that the latest resolvable (NOT the latest available) is 1.18.0
.
I don’t understand why, if collection
is using Semantic Versioning (I don’t know whether it is or not), it should be pinned like this (=1.18.0
), rather than pinned to a major version (^1.18.0
, which would allow 1.19.0
, 1.20.0
, etc.). Hopefully they will address this in the future.
Until then, unfortunately we have to pin to the version that Flutter supports, hence two things to keep in mind:
-
If you build any Dart packages that you or others will depend on, avoid requiring the very latest minor version of
collection
. -
You can easily add collection using
dart pub add collection
, and it will automatically choose the correct version annotation inpubspec.yaml
.
1