ArchitectureMedium30 XP3 min read
Should you organize your Flutter app feature-first or layer-first?
TL;DR: Feature-first (lib/features/quiz/) scales better — all quiz-related code is co-located. Layer-first (lib/blocs/, lib/repositories/) leads to cross-folder changes for every feature and becomes hard to navigate as apps grow.
Full Answer
| Aspect | Feature-first | Layer-first |
|---|---|---|
| Structure | features/quiz/bloc, features/quiz/ui | blocs/quiz, repositories/quiz |
| Cohesion | High — related code in one place | Low — feature spread across folders |
| Scalability | Better — add feature folder, done | Poorer — changes touch 5 folders |
| Navigation | Feature scope is clear | Hard to find what belongs to what |
| Team size | Better for teams per feature | OK for very small projects |
🎯
Robert C. Martin's 'screaming architecture': your folder structure should tell you what the app does, not what framework it uses. features/quiz screams quiz; blocs/ screams BLoC.
Code Examples
dartFeature-first structure
Output
// Feature-first: 'where is quiz code?' -> features/quiz/ // Layer-first: check blocs/, repos/, models/, pages/...
Common Mistakes
- ✗Mixing both structures — use a consistent approach across the entire codebase
- ✗Shared/ folder growing too large — if it has more than 10-15 items, refactor into a feature
Interview Tip
💡
This question tests architectural thinking beyond code. Mention that Flutter teams at large companies universally prefer feature-first for maintainability.
#folder-structure#feature-first#layer-first#modularity