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:
- Feature Architecture
- UI Kit
- Navigation
- (upcoming) State & Providers
๐ฏ 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).
๐ Recommended Project Layoutโ
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
NavigationZoneRouteenums. - 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.