Reputation: 3313
I have a silly question regarding dev_dependencies in flutter, I am planning to use mock_cloud_firestore
and in its installation page it says that we need to add it in the dependencies
section of pubspec.yaml
I think mock_cloud_firestore
is not a production dependency but a dev dependency if so why we need to add it under dependencies?
Also what we add under dev_dependencies
?
Thanks.
Upvotes: 6
Views: 4956
Reputation: 5095
you can run below command flutter pub add <packagename> --dev
to add under dev dependencies
and you can run below command flutter pub add <packagename>
to add normal dependencies.
Both make an entry within the pubspec.yaml file under different headers.
dev_dependencies only have packages and tools which help the development process for the developer and are not really needed in production . eg. code generation etc
Upvotes: 11
Reputation: 3018
This issue is mentioned in Dart's official docs:
Pub supports two flavors of dependencies: regular dependencies and dev dependencies. Dev dependencies differ from regular dependencies in that dev dependencies of packages you depend on are ignored
Therefore, I believe it safer to put it under dependencies during development and remove it from pubspec when personal testing is finished. But below quote from the official doc is more clear:
The rule for deciding between a regular or dev dependency is simple: If the dependency is imported from something in your lib or bin directories, it needs to be a regular dependency. If it’s only imported from test, example, etc. it can and should be a dev dependency.
Upvotes: 4