2

We can add flutter dependencies by the following ways. I want to know which one is efficient and also the differences between the following ways

  1. 'cupertino_icons: ^1.0.2' // What's the use if we use version number
  2. 'cupertino_icons: ' // What if we don't mention the version number
  3. 'cupertino_icons: any' // difference between (2 and 3)
Anand
  • 4,355
  • 2
  • 35
  • 45
  • https://dart.dev/tools/pub/dependencies#hosted-packages – mmcdon20 Dec 08 '22 at 07:13
  • @mmcdon20 Thanks for your answer. But I already saw that post , There is no answer for point no.2 and 3 – Anand Dec 08 '22 at 07:15
  • 1
    It says "If no version constraint is given, any is assumed." which means 2 and 3 are the same. – mmcdon20 Dec 08 '22 at 07:16
  • 1
    ``The string any allows any version. This is equivalent to an empty version constraint, but is more explicit. Although any is allowed, we don’t recommend it.`` – OMi Shah Dec 08 '22 at 07:43

1 Answers1

1

When you add dependency like cupertino_icons: ^1.0.2 it will get any version between 1.0.2 and 2.0.0 and looks for compatible version with your flutter and dart version and other packages,

when you add dependency like cupertino_icons: any it will get any version that compatible with your flutter and dart version and other packages.

also there is another version that is cupertino_icons: 1.0.2 which get exact 1.0.2 version of cupertino_icons.

eamirho3ein
  • 16,619
  • 2
  • 12
  • 23