Is there any benefit to use `src` sub-folder inside `lib` folder

This question is tagged as Flutter but should probably also have the Dart flag as Dart is the language used by Flutter. According to Dart Organising a library Package, the convention of putting code under lib/src is called a "convention" and the purpose is to separate the library's public code from private implementation code.

There is a second reason further down that states:

Tip for web apps: For the best performance when developing with dartdevc, put implementation files under /lib/src, instead of elsewhere under /lib. Also, avoid imports of package:package_name/src/....

As the dartdevc compiler is used by flutter at development time in debug mode (see Flutter Debug Build mode), there does appear to be a design-time speed advantage with hot reload if you use the lib/src structure rather than just lib. Please note a different compiler is used for release - dart2js - so there is no advantage in this scenario (see the same link above).

A similar historical discussion on the above points can be found on the dart language github here: Recommendations for /lib/src vs. /lib

Tags:

Dart

Flutter