A production-ready, highly scalable Flutter template designed for modern application development. It implements strictly typed Clean Architecture with Riverpod for state management and dependency injection, and ships with a working example of nearly every integration pattern a real app eventually needs β REST, WebSocket, webhooks, GraphQL, gRPC, background tasks, biometrics, offline sync, and more β so you can start from "already solved" instead of "figure it out."
- Strict Clean Architecture: clear separation of Domain, Data, and Presentation layers, generated consistently for every feature.
- Functional Error Handling: uses
fpdartfor type-safe error handling (Either<Failure, T>) instead of throwing. - Riverpod 3.x: modern provider patterns with
Notifier,AsyncNotifier, and code-generated (riverpod_generator) providers. - Framework Independence: Domain and Data layers are testable without any Flutter dependency.
- Feature Generator: create a complete feature β domain, data, presentation, tests β in seconds (
./generate_feature.sh). - Strict Linting: an opinionated
analysis_options.yamlplusriverpod_lint/custom_lint, kept at zero issues. - CI/CD Ready: GitHub Actions run
dart format,flutter analyze, andflutter teston every push and PR. - Type Safety: full null-safety and strict typing throughout,
freezed/json_serializablefor models.
- Auth, Tasks, Posts, Notifications, Survey, Chat: complete, working features built on the architecture, not just docs describing it.
- Offline First: local storage and sync strategies with Hive/SharedPreferences/
flutter_secure_storage. - Biometric Auth: Face ID / fingerprint gating both app access and sensitive actions.
- Localization: multi-language support (
intl+ custom ARB tooling) with a runtime language switcher. - A full integration example gallery β see below.
This template ships small, copyable examples of the integration and platform patterns most apps need sooner or later, so you can pick the one your requirement matches and adapt it instead of researching it from scratch. Run the app, sign in, and tap Examples (home screen tile, or the compass icon in the bottom nav) to browse all of them β or jump straight to the source under lib/examples/examples_hub_screen.dart.
| Pattern | Where | Notes |
|---|---|---|
| REST | features/posts/ (uses core/network/api_client.dart) |
Repository pattern over Dio, with offline cache fallback |
| WebSocket | core/network/integrations/websocket_client.dart |
Connect/send/receive/reconnect; demoed against a public echo server |
| Webhook (send) | core/network/integrations/webhook_sender.dart + webhook_signature.dart |
HMAC-SHA256 signed outbound POST |
| Webhook (receive) | core/network/integrations/local_webhook_receiver.dart |
Local-only dart:io HttpServer for dev/testing; not available on web |
| GraphQL | core/network/integrations/graphql_client.dart |
Thin Dio wrapper β a query and a mutation, no extra state-management framework |
| gRPC | core/network/integrations/grpc/ |
Real protoc-generated client for a unary + a server-streaming call; not available on web. Run dart run tool/grpc_demo_server.dart locally to exercise the streaming call end-to-end |
| Background tasks | core/background/background_task_service.dart |
workmanager: one-off and periodic scheduled work, survives the app being closed |
| Biometric auth | core/auth/local_biometric_service.dart + examples/biometrics_demo.dart |
Fingerprint/Face ID gating app access and sensitive transactions |
| File upload/download | core/network/integrations/file_transfer_service.dart |
Multipart upload and download, both with progress callbacks; not available on web |
| Feature flags, analytics, notifications, images, logging, accessibility, app updates, offline sync, app reviews | examples/advanced_features_showcase.dart |
One screen touring the rest of core/ |
A few of these (the local webhook receiver, gRPC, and file transfer to disk) need a real filesystem or raw TCP socket and are intentionally unavailable on Flutter Web β each says so in its own screen and doc comment rather than failing silently.
The full guide set lives in docs/ and is published as a static site at ssoad.github.io/flutter_riverpod_clean_architecture (rebuilt automatically on every push to docs/). The most useful starting points:
| Guide | What it covers |
|---|---|
| Getting Started | The fastest path from clone to running app |
| Architecture Guide | The Clean Architecture layering this template enforces |
| Coding Standards | Naming, structure, and lint conventions used throughout |
| CLI Tools | The generator/rename/icon scripts, in more depth than below |
| Features | What each built-in feature does |
| Examples | Deeper walkthroughs of specific patterns |
| CI/CD Guide | How the GitHub Actions workflows are wired up |
| Contributing | How to propose changes to this template |
Plus focused guides for individual subsystems: Localization, Biometric Auth, Offline Architecture, Feature Flags, Analytics, Accessibility, and Image Handling.
- Flutter SDK, latest stable channel (developed and CI-tested against 3.35+)
- Dart SDK 3.10+ (bundled with the Flutter SDK above)
# Clone the repository
git clone https://github.com/ssoad/flutter_riverpod_clean_architecture.git
cd flutter_riverpod_clean_architecture
# Install dependencies
flutter pub get
# Generate code (Freezed, Riverpod, JSON serialization)
dart run build_runner build --delete-conflicting-outputs# Development
flutter run
# Production build
flutter build apk --releaseFive scripts automate the parts of starting a new project that are otherwise tedious and error-prone. All are executable (chmod +x already set) and safe to run from the repo root; see docs/TOOLS.md for full detail on each.
./generate_feature.sh --name my_awesome_featureScaffolds a complete feature module β domain/{entities,repositories,usecases}, data/{models,datasources,repositories}, presentation/{providers,screens,widgets}, a providers/ DI file, and unit tests for every layer β following the same structure as every existing feature.
./rename_app.sh --app-name "My Super App" --package-name com.company.superappUpdates the display name and package/bundle identifier across Android, iOS, macOS, Windows, Linux and Web, moves the Kotlin package directory, and rewrites internal package:... Dart imports. Cross-platform (works with both BSD/macOS and GNU/Linux sed).
# 1. Place a 1024x1024 source icon at assets/icon/app_icon.png
# 2. Run:
./generate_icons.shGenerates native icons for Android mipmap, iOS Assets.xcassets, Web manifest.json, and Windows/macOS/Linux via flutter_launcher_icons.
./generate_language.sh generate # regenerate the localization delegate from the ARB files
./generate_language.sh list # list supported languages
./generate_language.sh add <code> # scaffold a new language, e.g. `add fr`Also checks every non-English ARB file against intl_en.arb and reports any missing translation keys.
./test_generator.sh # run all tests and generate an HTML coverage report
./test_generator.sh --no-coverage # skip coverage collection
./test_generator.sh --target test/features/auth # scope to a directorylib/
βββ core/ # Shared kernel: network, storage, auth, error handling, DI
β βββ network/
β β βββ integrations/ # WebSocket, webhook, GraphQL, gRPC, file transfer clients
β βββ background/ # WorkManager background task service
β βββ ... # accessibility, analytics, logging, theming, localization, ...
βββ examples/ # Copyable pattern examples, browsable via the in-app Examples Hub
β βββ integrations/ # Demo screens for each core/network/integrations/* client
βββ features/ # Feature modules (see structure below)
β βββ auth/ # Login, registration, profile
β βββ chat/ # WebSocket chat feature
β βββ tasks/ # Local CRUD to-do list
β βββ posts/ # Paginated feed with offline cache
β βββ notifications/ # In-app notification center
β βββ survey/ # Complex form handling
β βββ ...
βββ l10n/ # Localization delegate and helpers
βββ main.dart # Entry point
βββ ...
tool/
βββ grpc_demo_server.dart # Local reference gRPC server for the streaming example
test/ # Mirrors lib/, unit + widget + golden tests
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
# Run all tests
flutter test
# Update golden files after an intentional UI change
flutter test --update-goldens
# Run with coverage and an HTML report
./test_generator.sh- Unit tests for use cases, repositories, and data sources (
mocktailfor mocking). - Widget tests for reusable UI components.
- Golden tests for visual regression, with a small pixel-difference tolerance for cross-platform font rendering.
CI (.github/workflows/flutter_ci_cd.yml) runs dart format --set-exit-if-changed, flutter analyze, and flutter test on every push and pull request against main/develop.
See docs/CONTRIBUTING.md for the full guide. In short:
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a pull request
Distributed under the MIT License. See LICENSE for the full text.