Skip to main content

Flutter Project Structure

This document is the entry point into the Flutter Guide.
It defines how to organize a DartWay Flutter application and connects to more detailed guides:


๐ŸŽฏ Core Principlesโ€‹

  • Feature-based โ†’ everything is split into small, isolated features.
  • Minimal boilerplate โ†’ no abstractions just for the sake of architecture.
  • Generic data layer โ†’ no repositories, no manual sync, everything goes through DartWay data layer.
  • AI-friendly โ†’ the structure is optimized for assistants (Cursor, ChatGPT).

lib/
โ”œโ”€ admin/ # Features for admin panel
โ”œโ”€ app/ # Main application features
โ”‚ โ”œโ”€ home/
โ”‚ โ”‚ โ”œโ”€ home_page/
โ”‚ โ”‚ โ”œโ”€ promotion_block/
โ”‚ โ”‚ โ””โ”€ ...
โ”‚ โ”œโ”€ profile/
โ”‚ โ””โ”€ ...
โ”œโ”€ auth/ # Authentication (login, signup, tokens)
โ”œโ”€ common/ # Shared utilities, configs, navigation
โ”œโ”€ core/ # Global configuration (router, providers, services)
โ”œโ”€ domain/ # Business logic on top of models (shared, cross-feature)
โ”œโ”€ ui_kit/ # Unified entry point for design system
โ”‚ โ””โ”€ ui_kit.dart
โ”œโ”€ build_info.dart # build configuration vars (generated automatically)
โ””โ”€ main.dart # App entry point

๐Ÿ‘‰ For large apps, you may create multiple app_* modules (e.g. /app_orders, /app_chat) โ€” the same rules apply.


๐Ÿ“ฆ Featuresโ€‹

Every feature is a small, self-contained folder with:

  • Entry Point โ†’ exactly one public file (page, widget, or context extension).
  • Widgets โ†’ UI parts for layout and interactions.
  • Logic โ†’ local providers, enums, helpers (scoped to this feature).
  • Domain Extensions โ†’ cross-feature business logic belongs in /domain, never inside features.
  • UI Kit โ†’ all styling and reusable visuals come only from ui_kit.dart.

๐Ÿ‘‰ For details and examples, see Feature Architecture.


๐ŸŽจ UI Kitโ€‹

  • UI Kit is the only allowed source of styles.
  • Inside app/, auth/, common/ you must not use directly:
    Color, TextStyle, BorderRadius, context.textTheme, context.colorScheme.
  • All features import only ui_kit.dart.

๐Ÿ‘‰ See UI Kit Guide.


๐Ÿงญ Navigationโ€‹

  • Routes are defined with NavigationZoneRoute enums.
  • Use context extensions (context.goTo, context.pushTo).
  • Redirects and guards are configured centrally in router.

๐Ÿ‘‰ See Navigation Guide.


๐Ÿงช Testsโ€‹

  • Every feature must include tests:
    • Widget tests for pages and components.
    • Provider tests for logic.
  • Place them in /test/feature_name/....

Tests ensure stability and make AI-generated code safer to adopt.


๐Ÿ“ˆ Scaling the Projectโ€‹

  • Keep features small. If a widget grows into a mini-flow, extract it as its own feature.
  • For large domains, split into app_* modules while keeping the same folder rules.
  • Domain logic must always remain in /domain, never spread across features.
  • All visuals remain in /ui_kit, ensuring consistent design.

โœ… Key Takeawaysโ€‹

  • Start from this structure in every DartWay Flutter project.
  • Features are the building blocks โ€” each with one public entry point.
  • Styling = UI Kit, business logic = Domain, navigation = Router.
  • Tests are mandatory.
  • Follow this consistently โ†’ predictable, maintainable, AI-friendly apps.