Creating Dart libraries
A Dart library can be composed of a single file or multiple files. In the most common and recommended way, when you create a file, you create a small library. But, if you prefer, you can split a library definition into multiple files. Although less common, it can be useful depending on the context, especially when working with very interdependent classes, for example.
The decision for splitting is important, not only for encapsulation but also for how library customers will import and use them. Let's say, for example, that we have two tightly coupled classes that need to live together for them to work. Dividing them into different libraries will force customers to import both libraries. This is not the most practical ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access