Import dart file outside lib directory

Posted by Ramesh Singh | Updated on

Import dart file outside lib directory. Importing files from outside lib/ is not supposed to work. This would prevent publishing packages to pub.dartlang.org because only lib/ and bin/ are downloaded when added to dependencies.

What you can do is to create a new package, that can even be located in a directory of another package (for example my_proj/example/example1) or outside of the project and then add it as a dependency to your primary project and import files from that package using package imports like import “package:example1/example1.dart”.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers