Dart Advanced Chapter 12 of 15
Libraries and Packages
Organize code into files and libraries, control what you import, use packages from pub.dev and publish your own.
No real program lives in one file. This chapter shows how Dart code is split up, how files find each other, and how to use the tens of thousands of free packages other developers have shared.
Lessons in this chapter
- Imports in Dart: import, as, show and hideLearn how to import libraries in Dart: core libraries, packages and your own files, with prefixes (as) and the show and hide keywords.
- Creating Your Own Libraries in DartLearn to organize Dart code into libraries: split files, structure the lib folder, use export to build a public API, and keep details private.
- Using Packages from pub.dev in DartLearn to find, add, use and update Dart packages from pub.dev: pubspec.yaml, dart pub add, version constraints and pubspec.lock.
- Creating and Publishing a Dart PackageStep-by-step guide to creating a Dart package and publishing it on pub.dev: structure, pubspec, docs, tests, versioning and dart pub publish.