Skip to content

ssoad/flutter_riverpod_clean_architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flutter Riverpod Clean Architecture Template

Flutter Riverpod Architecture License

A production-ready, highly scalable Flutter template designed for modern application development. This project implements strictly typed Clean Architecture with Riverpod for state management and dependency injection.


πŸš€ Key Features

Core Architecture

  • Strict Clean Architecture: Clear separation of Domain, Data, and Presentation layers.
  • Functional Error Handling: Uses fpdart for type-safe error handling (Either<Failure, T>).
  • Riverpod 2.0: Modern provider patterns with Notifier and AsyncNotifier.
  • Framework Independence: Domain and Data layers are testable without Flutter dependencies.

Developer Experience

  • Feature Generator: Create complete features in seconds (./generate_feature.sh).
  • Strict Linting: Zero-tolerance analysis options for code quality.
  • CI/CD Ready: GitHub Actions workflows for automated testing and analysis.
  • Type Safety: Full null-safety and strict typing throughout.

Advanced Capabilities

  • Real-Time Features: WebSocket integration example (Chat).
  • Complex Forms: Advanced form handling with validation (Survey).
  • Offline First: Local storage strategies with Hive/SharedPreferences.
  • Secure Storage: Encrypted credential storage.
  • Biometric Auth: FaceID and Fingerprint integration.
  • Localization: Built-in multi-language support.

πŸ“š Documentation


πŸ› οΈ Quick Start

1. Prerequisites

  • Flutter SDK (3.7+)
  • Dart SDK (3.0+)

2. Installation

# Clone the repository
git clone https://github.com/ssoad/flutter_riverpod_clean_architecture.git

# Install dependencies
flutter pub get

# Generate code (Freezed, Riverpod, etc.)
dart run build_runner build --delete-conflicting-outputs

3. Running the App

# Development
flutter run

# Production Build
flutter build apk --release

⚑ Generating New Features

Don't write boilerplate manually! Use the included generator script:

# Generate a full feature with UI, Domain, and Data layers
./generate_feature.sh --name my_awesome_feature

This creates:

  • domain/entities/, repositories/, usecases/
  • data/models/, datasources/, repositories/
  • presentation/providers/, screens/, widgets/
  • providers/ (DI configuration)
  • Unit tests for all layers

πŸ“¦ App Renaming

Start your project with the right identity! Use our renaming utility:

./rename_app.sh --app-name "My Super App" --package-name com.company.superapp

This updates:

  • Android: AndroidManifest.xml, build.gradle, Kotlin files
  • iOS: Info.plist, Project files
  • macOS, Windows, Linux Build files
  • Dart package name & imports

🎨 Icon Generation

Generate native app icons for all platforms in one command:

  1. Place your icon file (1024x1024) at assets/icon/app_icon.png.
  2. Run the generator script:
./generate_icons.sh

This updates:

  • Android mipmap resources
  • iOS Assets.xcassets
  • Web manifest.json and icons
  • Windows/macOS/Linux icon files

πŸ—οΈ Project Structure

lib/
β”œβ”€β”€ core/                       # Shared kernel (Errors, Network, Utils)
β”œβ”€β”€ features/                   # Feature modules
β”‚   β”œβ”€β”€ auth/                   # Authentication Feature
β”‚   β”œβ”€β”€ chat/                   # WebSocket Chat Feature
β”‚   β”œβ”€β”€ survey/                 # Complex Form Feature
β”‚   └── ...
β”œβ”€β”€ main.dart                   # Entry point
└── ...

Feature Structure (The "Screaming Architecture")

Each feature is a self-contained module:

feature_name/
β”œβ”€β”€ domain/                     # 1. Innermost Layer (Pure Dart)
β”‚   β”œβ”€β”€ entities/               # Business objects (Equatable)
β”‚   β”œβ”€β”€ repositories/           # Abstract interfaces
β”‚   └── usecases/               # Business logic units
β”œβ”€β”€ data/                       # 2. Outer Layer (Implementation)
β”‚   β”œβ”€β”€ datasources/            # API/DB clients
β”‚   β”œβ”€β”€ models/                 # JSON parsing & Adapters
β”‚   └── repositories/           # Repository implementations
β”œβ”€β”€ presentation/               # 3. UI Layer (Flutter)
β”‚   β”œβ”€β”€ providers/              # UI State Management (Notifiers)
β”‚   β”œβ”€β”€ screens/                # Widget pages
β”‚   └── widgets/                # Reusable components
└── providers/                  # 4. DI Layer (Riverpod)
    └── feature_providers.dart  # Data layer dependency injection

πŸ§ͺ Testing

We use a comprehensive testing strategy:

  • Unit Tests: For Use Cases, Repositories, and Data Sources.
  • Widget Tests: For reusable UI components.
  • Golden Tests: For visual regression testing of screens.
# Run all tests
flutter test

# Update Golden files
flutter test --update-goldens

🀝 Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.