Skip to content
flutter-riverpod-architecture logo

Flutter + Riverpod Clean Architecture

flutter-riverpod-architecture

Clean Architecture patterns for Flutter with Riverpod state management. Use when building or reviewing Flutter apps with layered architecture (Domain, Data, Application, Presentation).

SKILL.md

Full skill instructions

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

LayerCan Depend OnCannot Depend On
DomainNothing (pure Dart)Flutter, Riverpod, Firebase, any SDK
DataDomainFlutter, Riverpod, Presentation
ApplicationDomain, DataFlutter UI classes
PresentationApplication, DomainData (direct access)

Quick Reference

LayerPrimary PurposeKey Technology
DomainBusiness entities, Value ObjectsFreezed, pure Dart
DataRepository implementations, API callsFirebase, HTTP clients
ApplicationState management, Provider definitionsRiverpod, AsyncNotifier
PresentationUI components, routingConsumerWidget, 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

  1. New Entity? -> See references/​domain-layer.md
  2. API Integration? -> See references/​data-layer.md
  3. State Management? -> See references/​application-layer.md
  4. Building UI? -> See references/​presentation-layer.md
  5. 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.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View