4

In our Flutter app we tried to move implementation of several features in their own packages.

Everything is working well, but there is one thing I would like to improve.

Some features use same third party libraries => ie. there are same dependencies in the pubspec.yaml

But that also means, everytime we need to update the version of a third party library we need to do this in all packages.

Is it possible to have a central file containing all dependency versions as variables that could be used in the corresponding pubspec.yaml files?

Or maybe there is any other workaround?

Tima
  • 12,765
  • 23
  • 82
  • 125

1 Answers1

0

Well I believe what you could do is instead of specifying a definite version of the third party library you could use the caret sign(^) in front of your third party library version (What is the caret sign (^) before the dependency version number in Flutter's pubspec.yaml?)

Since the caret sign, specifies that when you flutter pub upgrade you update the library up to the last non-breaking version, it should fix your issue.

And when a breaking version is coming along you do not want it to be updated everywhere anyway, since you need to test and modify every package individually, to make sure that it works properly. Does that sound like a correct answer ?

Mike
  • 348
  • 2
  • 8
  • Somehow my comment dissapeared. It's not really a solution in case we want to use a specific version (but not the latest one) in all packages. – Tima Sep 09 '20 at 07:02
  • 1
    You are totally right, and I know that my answer is a bit off and doesn't answer your problem directly, however I do not know of a better way for the time being. I will upvote your question in pursuit of a better answer. – Mike Sep 09 '20 at 08:19
  • I guess there is unfortunately no other solution. But who knows. I thought, maybe someone developed an android studio plugin or maybe there is yaml generator – Tima Sep 09 '20 at 09:56