Skill

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).

From flutter-riverpod-architecture
Install
1
Run in your terminal
$
npx claudepluginhub xmgrex/ccx-arsenal --plugin flutter-riverpod-architecture
Tool Access

This skill uses the workspace's default tool permissions.

Supporting Assets
View in Repository
references/application-layer.md
references/data-layer.md
references/domain-layer.md
references/presentation-layer.md
references/ui-patterns.md
Skill Content

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.

Similar Skills
cache-components

Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.

138.5k
Stats
Parent Repo Stars1
Parent Repo Forks0
Last CommitJan 30, 2026