-
Notifications
You must be signed in to change notification settings - Fork 0
Explanation of directory structure
The structure takes inspiration from Matt Rešetár's Clean Architecture course.
lib/
├───core
│ ├───constants
│ ├───data
│ ├───domain
│ ├───presentation
│ └───theme
├───features
│ ├───timetable
│ │ ├───data
│ │ ├───domain
│ │ └───presentation
│ └───<etc.>
└───screens
├───AboutScreen.dart
└───<etc.>
The core
directory contains code that is used in multiple places in the app. Code in the core
directory should not depend on any other directories. But other directories may, and should if needed, depend on the core
directory.
Package-by-feature uses directories to reflect the features that exists in the app. It holds code related to a single feature together in a single directory. One feature directory will not depend on another feature directory (one feature should not depend on another feature in the app).
If one feature directory really needs to depend on another feature directory. Consider moving the dependency into the core
folder if it is used by many other parts of your code, or combining the two feature directories into a single directory.
There are actually more sub-directories within these directories:
├───data
│ ├───data_sources
│ ├───models
│ └───repositories
├───domain
│ ├───entities
│ ├───repositories
│ └───use_cases
└───presentation
├───bloc
└───widgets
Please see Matt Rešetár's Clean Architecture course on more explanation on each of these sub-directories.
The screens
directory holds classes in the form of FooScreen.dart
. These are usually Widgets
that represent a navigation destination. Widget
s in the screens
directory may depend on one or more feature directories. No other code should depend on Widget
s in the screens
directory.