Title: In Flutter, Dependencies must specify version number?
Tags: dart;flutter
Question: Typically, you have to add something like 

```dependencies:
  camera: "^0.2.0"
```

to the pubspec.yaml file. What happens if I don't include the version number? It's a small thing, but usually, I find a piece of code and want to test it. At the top, I see something like >> 

```import 'package:camera/camera.dart';
```

Do I have to go to the package's homepage to find the version number?


Here is the accepted answer: You can use ```any```

```dependencies:
  camera: any
```

Having tighter constraints makes it easier for ```packages get```/```packages upgrade``` to search matching versions because it reduces the solution space, but for simple examples it usually doesn't matter.

```pub``` got an improved solver recently that makes ```any``` much less of a problem than it used to be where ```pub``` often just timed out when ```any``` was used.

Comment for this answer: Thanks @Günter Zöchbauer
Comment for this answer: Note: You can also use git links.

Here is another answer: as per https://www.dartlang.org/tools/pub/dependencies

```
  Based on what data you want to provide, you can specify dependencies
  in two ways. The shortest way is to just specify a name:
```

```dependencies:
  transmogrify:
```

```
  This creates a dependency on transmogrify that allows any version,
  and looks it up using the default source, which is pub.dartlang.org.
  To limit the dependency to a range of versions, you can provide a
  version constraint:
```

dependencies:
  transmogrify: ^1.0.0

```
  This creates a dependency on transmogrify using the default source and
  allowing any version from 1.0.0 to 2.0.0 (but not including 2.0.0).
  See Version constraints and Caret syntax for details on the version
  constraint syntax.
```

I guess that the real answer to my question is that usually, it's best to specify a major version number ratio e.g.: ^1.0.0 == 1.0.0 < 2.0.0. This is to say that this program works and is tested and will keep working with this library dependancy so long as there are no major changes.

Comment for this answer: @AliAzad Yes, `transmogrify:` will use the last version.
Comment for this answer: Is this mean, dependencies: transmogrify: will use the last version of this package?

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:05/25/18', 'FavoriteCount': 3.0, 'PostTypeId': 1, 'Tags': '<dart><flutter>', 'Title': 'In Flutter, Dependencies must specify version number?', 'ViewCount': 7188, 'id': 50533553, 'user_AboutMe': '', 'user_AccountId': 51410.0, 'user_DisplayName': 'naim5am', 'user_Reputation': 1274.0, 'user_Views': 119.0, 'user_id': 153614.0}}