FolderStructure.dev

Flutter Feature-First Project Structure

Feature-based architecture where each feature is a self-contained module. Scales well for team development.

#flutter #dart #mobile #ios #android #feature-first #modular
PNGPDF

Project Directory

myapp/
pubspec.yaml
Dependencies and app metadata
pubspec.lock
analysis_options.yaml
Linting rules
.gitignore
README.md
lib/
main.dart
App entry point
app.dart
MaterialApp configuration
core/
Shared app-wide code
constants/
app_colors.dart
app_strings.dart
app_sizes.dart
theme/
app_theme.dart
utils/
validators.dart
extensions.dart
network/
api_client.dart
api_endpoints.dart
shared/
Shared widgets and models
widgets/
loading_indicator.dart
error_widget.dart
custom_button.dart
models/
user.dart
features/
Self-contained features
auth/
Authentication feature
screens/
login_screen.dart
register_screen.dart
widgets/
auth_form.dart
providers/
auth_provider.dart
services/
auth_service.dart
home/
Home/dashboard feature
screens/
home_screen.dart
widgets/
dashboard_card.dart
providers/
home_provider.dart
settings/
Settings feature
screens/
settings_screen.dart
providers/
settings_provider.dart
routing/
App navigation
app_router.dart
routes.dart
test/
features/
auth/
auth_provider_test.dart
shared/
widgets_test.dart
android/
app/
build.gradle
ios/
Runner/
Podfile
assets/
images/
fonts/
icons/

Why This Structure?

Feature-first organizes code by what it does, not what it is. Each feature (auth/, home/, settings/) contains its own screens, widgets, providers, and services. Add new features without touching existing code.

Key Directories

  • lib/features/-Self-contained feature modules
  • lib/core/-App-wide constants, theme, network, utils
  • lib/shared/-Widgets and models used across features
  • lib/routing/-Centralized navigation configuration
  • feature/providers/-State management per feature

Getting Started

  1. flutter create myapp
  2. Set up folder structure: lib/core/, lib/shared/, lib/features/
  3. flutter pub add provider go_router
  4. Create first feature module in lib/features/
  5. flutter run

When To Use This

  • Apps with 5+ distinct features
  • Team development (each dev owns features)
  • Features that can be added/removed independently
  • Medium-sized apps expecting growth
  • Need clear ownership boundaries

Trade-offs

  • More folders-Deeper nesting can feel verbose
  • Cross-feature sharing-Must decide what goes in shared vs feature
  • Initial setup-More structure to scaffold upfront

Best Practices

  • Keep features truly independent—avoid direct imports between features
  • Use shared/ for widgets used by 2+ features
  • Put business logic in providers/ or services/, not widgets
  • Feature folders mirror test folder structure

Naming Conventions

  • Features-Lowercase, noun-based (auth, home, profile, cart)
  • Screens-snake_case with _screen suffix
  • Widgets-snake_case describing the component
  • Providers-snake_case with _provider suffix