Skip to content

Flutter Clean Architecture starter with Feature-First structure, BLoC/Cubit, GetIt DI, Material 3 themes, and built-in localization. Perfect for production apps.

License

Notifications You must be signed in to change notification settings

zfarzaneh/flutter-clean-app-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ Flutter Clean App Base

A production-ready Flutter starter template designed with Clean Architecture, a feature-first structure, and built-in support for localization, theming, and global text scaling.

This template provides a clean foundation for building real applications with a scalable, maintainable architecture. It includes modern best practices and a modular layout suitable for both small and enterprise-level apps.

✨ Features

  • 🌱 Feature-First + Clean Architecture
  • πŸ›οΈ BLoC / Cubit for state management
  • πŸ“¦ GetIt as the service locator (DI)
  • 🎨 Material 3 with Light, Dark, and System theme modes
  • 🌍 Localization (English & Persian) with system locale detection
  • πŸ”€ Global text scaling with user-controlled font size
  • πŸ–ΌοΈ Custom Android & iOS launcher icons
  • 🎞️ Modern animated splash screen
  • 🧩 Clean modular folder structure

πŸ“Έ Screenshots

Dark & Light mode, Localization (EN/FA), and Global Text Scaling

Light Mode
Dark Mode
Home Page

Note: You can replace the paths with your actual assets or GitHub image URLs.

πŸ“ Folder Structure

A clean, scalable structure based on Feature-First + Clean Architecture:

lib/
β”‚
β”œβ”€β”€ config/                      # Global app-level configuration
β”‚   β”œβ”€β”€ di/                      # Dependency injection (GetIt)
β”‚   β”œβ”€β”€ localization/            # ARB, localization cubit, delegates
β”‚   β”œβ”€β”€ router/                  # AppRouter + route definitions
β”‚   └── shared_prefs/            # Persistence (.gitkeep only)
β”‚
β”œβ”€β”€ theme/                       # Material 3 themes, color schemes, theme cubit
β”‚
β”œβ”€β”€ core/                        # Shared utilities across features
β”‚   β”œβ”€β”€ constants/
β”‚   β”œβ”€β”€ error/
β”‚   β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ usecase/
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ extensions/              # Spacing extension lives here
β”‚   └── widgets/                 # AppWrapper, global widgets
β”‚
β”œβ”€β”€ features/                    # Main feature modules
β”‚   β”œβ”€β”€ feature_home/
β”‚   β”œβ”€β”€ feature_explore/
β”‚   └── feature_settings/
β”‚
β”œβ”€β”€ feature_shell/               # Bottom navigation + tab layout
β”‚
└── main.dart                    # Entry point

Key ideas:

  • Each feature has its own presentation/data/domain layers (expandable later)
  • All shared logic stays under core/
  • Clean separation of UI, business logic, DI, and system services

πŸ“¦ Getting Started

Clone the repository

git clone https://github.com/zfarzaneh/flutter-clean-app-base.git
cd flutter-clean-app-base

Install dependencies

flutter pub get

Run code generation (localization)

flutter gen-l10n

Setup DI (GetIt) The project uses a simple service locator. All dependencies are registered in:

lib/config/di/locator.dart

Make sure setupLocator() is called before runApp():

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await setupLocator();
  runApp(const AppWrapper());
}

Run the app

flutter run

πŸš€ Running & Building

πŸ“± Run the app in debug mode

flutter run

▢️ Run with a specific device

flutter run -d chrome
# or
flutter run -d emulator-5554

πŸ§ͺ Run unit & widget tests

flutter test

πŸ“¦ Build release APK

flutter build apk --release

🍎 Build for iOS (requires macOS)

flutter build ios --release

🌐 Build web release

flutter build web --release

🧱 Architecture Overview

This project follows a Clean Architecture + Feature-First structure, designed for scalability, readability, and long-term maintainability.

The architecture is based on four core principles:

  1. Separation of concerns
  2. UI independent from business logic
  3. Testability and clean boundaries
  4. Feature isolation (modular development)

Below is an overview of each major layer:


1️⃣ Presentation Layer (UI + State Management)

Located inside:

lib/features/**/presentation

This layer contains:

  • Pages / Screens
  • Widgets
  • Cubit / Bloc (application state)
  • Localization text usage
  • Theme-aware UI components

The presentation layer communicates only with the Domain layer through UseCases or Cubits.


2️⃣ Domain Layer (Business Rules)

Located inside:

lib/features/**/domain

This layer contains:

  • Entities
  • Repositories (abstract interfaces)
  • Use Cases (business logic)

The domain layer is pure Dart β€” it has no dependency on Flutter or any external package.
This allows easy testing and makes the business logic reusable.


3️⃣ Data Layer (External Sources)

Located inside:

lib/features/**/data

It provides implementations for:

  • Repository interfaces
  • API clients (Dio / HTTP)
  • Local storage
  • Mappers & DTOs

This layer converts external data formats (JSON, responses, prefs) into domain entities.


4️⃣ Core Layer (Shared Code Across the App)

Located inside:

lib/core

This contains:

  • Common widgets
  • Extensions (spacing, context helpers, etc.)
  • Shared utilities
  • Base Cubit/State classes
  • App-wide wrapper (themes, localization, navigation)

Core contains everything that multiple features may reuse.


5️⃣ Config Layer (App-Wide Configuration)

Located inside:

lib/config

This layer manages:

  • Dependency Injection (GetIt)
  • Theme system (light/dark)
  • Localization system (ARB + gen-l10n)
  • Routing
  • App color schemes
  • Global settings

This is where global systems live β€” not feature-specific logic.


🧩 Why Feature-First?

The project uses a feature-first structure, meaning each app module (Home, Explore, Settings, Auth, etc.) has its own:

data/ domain/ presentation/

Advantages:

  • No huge β€œscreens” folder
  • Each feature is isolated and easy to maintain
  • Easier onboarding for new developers
  • Better testability
  • Perfect for medium-to-large Flutter apps

πŸ›  How State Management Fits In

The project uses:

Cubit (via flutter_bloc)

  • UI listens to Cubit state streams
  • Cubits call repositories or use-cases
  • Repositories fetch data from remote/local sources

This ensures UI stays clean and reactive.


πŸ”Œ Dependency Injection (GetIt)

All repositories, services, and cubits register in:

lib/config/di/locator.dart

and are resolved throughout the app using:

sl<MyService>();

This completely removes the need for instantiating classes manually and makes unit testing easier.

🏁 Summary Diagram

Presentation (UI, Cubit)
        ↓
     Domain (UseCases, Entities)
        ↓
       Data (API, Local)
        ↓
      External (HTTP, Prefs)

Each layer depends only on the layer below it β€” never upward.

Clean, predictable, maintainable.

πŸ§ͺ Tests

This template currently does not include test files.
A testing setup (unit, widget, and integration tests) will be added in future updates.

πŸ“„ License

This project is licensed under the MIT License – feel free to use, modify, and distribute it.

See the LICENSE file for details.

About

Flutter Clean Architecture starter with Feature-First structure, BLoC/Cubit, GetIt DI, Material 3 themes, and built-in localization. Perfect for production apps.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published