Flutter + Riverpod Clean Architecture
Overview
This skill provides architectural patterns and rules for building Flutter applications using Clean Architecture with Riverpod for state management. Follow these patterns to maintain clear layer boundaries, testability, and scalability.
Architecture Layers
┌─────────────────────────────────────────┐
│ Presentation Layer │ Flutter UI, Widgets, Routing
├─────────────────────────────────────────┤
│ Application Layer │ Riverpod Providers, State Management
├─────────────────────────────────────────┤
│ Data Layer │ Repositories, External APIs
├─────────────────────────────────────────┤
│ Domain Layer │ Entities, Value Objects, Business Rules
└─────────────────────────────────────────┘
Layer Dependency Rules
| Layer |
Can Depend On |
Cannot Depend On |
| Domain |
Nothing (pure Dart) |
Flutter, Riverpod, Firebase, any SDK |
| Data |
Domain |
Flutter, Riverpod, Presentation |
| Application |
Domain, Data |
Flutter UI classes |
| Presentation |
Application, Domain |
Data (direct access) |
Quick Reference
| Layer |
Primary Purpose |
Key Technology |
| Domain |
Business entities, Value Objects |
Freezed, pure Dart |
| Data |
Repository implementations, API calls |
Firebase, HTTP clients |
| Application |
State management, Provider definitions |
Riverpod, AsyncNotifier |
| Presentation |
UI components, routing |
ConsumerWidget, go_router |
Layer References
references/domain-layer.md - Freezed entities, Value Objects, immutable data
references/data-layer.md - Repository pattern, dependency injection
references/application-layer.md - Riverpod providers, AsyncNotifier pattern
references/presentation-layer.md - ConsumerWidget, type-safe routing
references/ui-patterns.md - Widget composition, anti-patterns
Core Principles
1. Dependency Inversion
- Inner layers don't know about outer layers
- Domain is completely independent
- Data depends only on Domain
- Dependencies flow inward
2. Single Responsibility
- Each layer has a clear purpose
- Repositories handle data access only
- Providers handle state management only
- Widgets handle UI rendering only
3. Testability
- Domain layer is easily unit-testable (no dependencies)
- Data layer can mock external services
- Application layer can mock repositories
- Presentation layer can mock providers
Directory Structure (Recommended)
lib/
├── app/
│ ├── route/ # go_router configuration
│ └── providers/ # App-wide providers
├── features/
│ └── {feature}/
│ ├── domain/ # Entities, Value Objects
│ ├── data/ # Repositories
│ ├── application/ # Providers, Notifiers
│ └── presentation/# Screens, Widgets
└── shared/
├── domain/ # Shared entities
├── data/ # Shared repositories
└── widgets/ # Shared UI components
Getting Started
- New Entity? -> See
references/domain-layer.md
- API Integration? -> See
references/data-layer.md
- State Management? -> See
references/application-layer.md
- Building UI? -> See
references/presentation-layer.md
- Widget Patterns? -> See
references/ui-patterns.md
Compliance Verification
# Verify Domain layer purity
grep -r "package:flutter" lib/features/*/domain/
grep -r "riverpod" lib/features/*/domain/
# Verify Data layer isolation
grep -r "package:flutter" lib/features/*/data/
grep -r "riverpod" lib/features/*/data/
# Verify Presentation doesn't access Data directly
grep -r "features/.*/data/.*_repository" lib/features/*/presentation/
All commands should return empty results if architecture is properly maintained.
Source: xmgrex/ccx-arsenal — distributed by TomeVault.
1---2name: flutter-riverpod-architecture3description: Clean Architecture patterns for Flutter with Riverpod state management. Use when building or reviewing Flutter apps with layered architecture (Domain, Data, Application, Presentation). Use when this capability is needed.4---56# Flutter + Riverpod Clean Architecture78## Overview910This skill provides architectural patterns and rules for building Flutter applications using Clean Architecture with Riverpod for state management. Follow these patterns to maintain clear layer boundaries, testability, and scalability.1112## Architecture Layers1314```15┌─────────────────────────────────────────┐16│ Presentation Layer │ Flutter UI, Widgets, Routing17├─────────────────────────────────────────┤18│ Application Layer │ Riverpod Providers, State Management19├─────────────────────────────────────────┤20│ Data Layer │ Repositories, External APIs21├─────────────────────────────────────────┤22│ Domain Layer │ Entities, Value Objects, Business Rules23└─────────────────────────────────────────┘24```2526## Layer Dependency Rules2728| Layer | Can Depend On | Cannot Depend On |29|-------|---------------|------------------|30| **Domain** | Nothing (pure Dart) | Flutter, Riverpod, Firebase, any SDK |31| **Data** | Domain | Flutter, Riverpod, Presentation |32| **Application** | Domain, Data | Flutter UI classes |33| **Presentation** | Application, Domain | Data (direct access) |3435## Quick Reference3637| Layer | Primary Purpose | Key Technology |38|-------|-----------------|----------------|39| Domain | Business entities, Value Objects | Freezed, pure Dart |40| Data | Repository implementations, API calls | Firebase, HTTP clients |41| Application | State management, Provider definitions | Riverpod, AsyncNotifier |42| Presentation | UI components, routing | ConsumerWidget, go_router |4344## Layer References4546- `references/domain-layer.md` - Freezed entities, Value Objects, immutable data47- `references/data-layer.md` - Repository pattern, dependency injection48- `references/application-layer.md` - Riverpod providers, AsyncNotifier pattern49- `references/presentation-layer.md` - ConsumerWidget, type-safe routing50- `references/ui-patterns.md` - Widget composition, anti-patterns5152## Core Principles5354### 1. Dependency Inversion55- Inner layers don't know about outer layers56- Domain is completely independent57- Data depends only on Domain58- Dependencies flow inward5960### 2. Single Responsibility61- Each layer has a clear purpose62- Repositories handle data access only63- Providers handle state management only64- Widgets handle UI rendering only6566### 3. Testability67- Domain layer is easily unit-testable (no dependencies)68- Data layer can mock external services69- Application layer can mock repositories70- Presentation layer can mock providers7172## Directory Structure (Recommended)7374```75lib/76├── app/77│ ├── route/ # go_router configuration78│ └── providers/ # App-wide providers79├── features/80│ └── {feature}/81│ ├── domain/ # Entities, Value Objects82│ ├── data/ # Repositories83│ ├── application/ # Providers, Notifiers84│ └── presentation/# Screens, Widgets85└── shared/86 ├── domain/ # Shared entities87 ├── data/ # Shared repositories88 └── widgets/ # Shared UI components89```9091## Getting Started92931. **New Entity?** -> See `references/domain-layer.md`942. **API Integration?** -> See `references/data-layer.md`953. **State Management?** -> See `references/application-layer.md`964. **Building UI?** -> See `references/presentation-layer.md`975. **Widget Patterns?** -> See `references/ui-patterns.md`9899## Compliance Verification100101```bash102# Verify Domain layer purity103grep -r "package:flutter" lib/features/*/domain/104grep -r "riverpod" lib/features/*/domain/105106# Verify Data layer isolation107grep -r "package:flutter" lib/features/*/data/108grep -r "riverpod" lib/features/*/data/109110# Verify Presentation doesn't access Data directly111grep -r "features/.*/data/.*_repository" lib/features/*/presentation/112```113114All commands should return empty results if architecture is properly maintained.115116---117> Source: [xmgrex/ccx-arsenal](https://github.com/xmgrex/ccx-arsenal) — distributed by [TomeVault](https://tomevault.io).118<!-- tomevault:4.0:skill_md:2026-06-16 -->