Search code examples
dartdart-editordart-pub

What relevance do folders have in a dart project?


When I create a sub folder in a Dart Project in Dart Editor, immediately a package subfolder is created inside this sub folder. I have not read anywhere that sub folders have a special meaning for the project structure, but it appears they do. Anybody knows more?


Solution

  • The package subfolder holds symlinks to your Pub packages. You can read more about Pub and Pub packages at http://pub.dartlang.org/doc/.

    When you start a non-web project, the editor will automatically create package directories in your bin/ and test/ directories (but not in your lib/ directory). If you create a web project, a package directory is also created in the web/ folder.

    If you add a Pub dependency in the pubspec.yaml file and run pub install, your will see that the package folders will contain symlinks to the Pub package you just installed. If you are using Dart Editor, pub install will automatically run once you modify your pubspec,yaml file.

    If you create a subfolder inside any directory that contains one of these auto-generated package folders, the subfolder will get its own package directory. This way, you will have access to your Pub packages no matter how deeply you nest your code in a directory.