Chapter 3. Libraries

Dart programs are organized into modular units called libraries. We saw our first library in Chapter 1. You might imagine this was the points library shown at the end of that chapter, but in fact, it was our “Hello World” program. A trivial library perhaps, but a library all the same. Here it is again:

main(){  print('Hello World'); }

As you can see, there is no requirement for an explicit library declaration like the one we saw in points. Most libraries do have such a declaration, which is useful for various reasons we shall illustrate below. However, for quick, simple tasks, it is convenient to be able to just write a function and run it. In Dart we always seek to enable experimentation with the language with a minimum ...

Get The Dart Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.