Ultimately, there is no relation between your directory structure and the library keyword in Dart.
The dart directory structure comes from the recommended package layout conventions but are not enforced by the language in any way. They are only enforced if you try to use the pub package manager to publish (upload) your package to the official dart repository. Ultimately you can use whatever directory structure layout you choose. This one is recommended to keep consistency between packages, particularly for Open Source packages or applications which may have other external contributors.
The library
keyword in Dart is used in a way of namespacing. For instance the underscore private variables are only have library visibility. Anything in the same library can see/access your underscore variables. Anything outside of it cannot. You can use the part
and part of
keywords to make other files part of a library (regardless of where they are located in the directory structure).