Dart by Example: Pub

Pub is the package manager for Dart.

A typical package has this file structure:

  1. cool_package/
  2. bin/
  3. ice
  4. lib/
  5. sodas.dart
  6. src/
  7. pepsi.dart
  8. coke.dart
  9. example/
  10. soda_example.dart
  11. web/
  12. cool_app.dart
  13. index.html
  14. style.css
  15. pubspec.yaml
  16. README.md
  1. # pubspec.yaml
  2. name: cool_package # use separate package names with underscores
  3. version: 1.2.3 # use semver
  4. description: >
  5. A really cool package that allows you to
  6. reticulate your splines and transmogrify
  7. your unidirectional dataflow.
  8. author: John Ryan
  9. homepage: johnpryan.github.io
  10. environment:
  11. sdk: ">=0.12.0"
  12. documentation: http://docs.coolpackagedartlang.com
  13. dependencies:
  14. yaml: ^2.1.0
  15. frappe: ^0.4.0
  16. dev_dependencies:
  17. test: ^0.12.0
  18. dependency_overrides:
  19. stream_transformers: 0.2.0
  20. yaml:
  21. path: ../yaml

dependency_overrides force all packagesin the dependency graph to use a specific version(since only one version of a package is allowed.)

path: dependencies are convenient if multiple packages are being developed on a local machine.

For details, see pub package layout conventions.

by @jryanio | source | license