{
    "url": "https://delaparra-services.nl/skills/flutter-clean-arch",
    "locale": "en",
    "title": "Flutter Clean Arch | DeLaParra Services",
    "description": "Use when creating or auditing the layers of a Flutter feature or package - where a use case, repository, datasource, entity or model belongs; whether domain may import Flutter; whether a dependency between layers is inverted. Triggers on \"where does this go?\" in a feature, or a request for an architecture review.",
    "alternates": {
        "en": "https://delaparra-services.nl/skills/flutter-clean-arch",
        "nl": "https://delaparra-services.nl/nl/skills/flutter-clean-arch"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/skills/flutter-clean-arch.csv",
        "md": "https://delaparra-services.nl/skills/flutter-clean-arch.md",
        "json": "https://delaparra-services.nl/skills/flutter-clean-arch.json",
        "zip": "https://delaparra-services.nl/skills/flutter-clean-arch.zip",
        "pdf": "https://delaparra-services.nl/skills/flutter-clean-arch.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/skills/flutter-clean-arch.csv",
            "encodingFormat": "text/csv",
            "name": "flutter-clean-arch.csv"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-clean-arch.json",
            "encodingFormat": "application/json",
            "name": "flutter-clean-arch.json"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-clean-arch.md",
            "encodingFormat": "text/markdown",
            "name": "flutter-clean-arch.md"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-clean-arch.pdf",
            "encodingFormat": "application/pdf",
            "name": "flutter-clean-arch.pdf"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-clean-arch.zip",
            "encodingFormat": "application/zip",
            "name": "flutter-clean-arch.zip"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-clean-arch/download",
            "encodingFormat": "application/zip",
            "name": "flutter-clean-arch-files.zip"
        }
    ],
    "markdown": "# Flutter Clean Arch\n\n \n\nUse when creating or auditing the layers of a Flutter feature or package - where a use case, repository, datasource, entity or model belongs; whether domain may import Flutter; whether a dependency between layers is inverted. Triggers on \"where does this go?\" in a feature, or a request for an architecture review.\n\n \n\n**Licence** MIT\n\n \n\n**Source** gabuldev/flutter-skills\n\n [Download zip](<https://delaparra-services.nl/skills/flutter-clean-arch/download>)   \n\nYou are working with Clean Architecture in a Flutter project.\n\n \n\n## Layer Responsibilities\n\n \n\n```\n┌─────────────────────────────────────────┐\n│  PRESENTATION                           │\n│  Modules, Screens, Controllers (Cubits) │\n│  Only knows: Domain entities + Usecases │\n├─────────────────────────────────────────┤\n│  DOMAIN (pure Dart, no Flutter)         │\n│  Entities, Repository interfaces,       │\n│  Usecases                               │\n│  Depends on: nothing                    │\n├─────────────────────────────────────────┤\n│  DATA                                   │\n│  Models, Datasources, Repo impls        │\n│  Depends on: Domain interfaces + Dio    │\n└─────────────────────────────────────────┘\n```\n\n \n\n## Full Feature Scaffold\n\n \n\nWhen argument is ` scaffold ` or no argument, create all layers for ` <feature_name> `:\n\n \n\n### Domain Layer\n\n \n\n**entity (domain/entities/.dart):**\n\n \n\n```\nimport 'package:equatable/equatable.dart';\n\nclass <Feature> extends Equatable {\n  final String id;\n  final String name;\n  // Add all business-relevant fields (no JSON, no framework types)\n\n  const <Feature>({\n    required this.id,\n    required this.name,\n  });\n\n  @override\n  List<Object?> get props => [id, name];\n\n  <Feature> copyWith({String? id, String? name}) => <Feature>(\n    id: id ?? this.id,\n    name: name ?? this.name,\n  );\n}\n```\n\n \n\n**repository interface (domain/repositories/\\_repository.dart):**\n\n \n\n```\nimport '../entities/<feature>.dart';\n\nabstract class <Feature>Repository {\n  Future<List<<Feature>>> getAll();\n  Future<<Feature>> getById(String id);\n  Future<void> create(<Feature> entity);\n  Future<void> update(<Feature> entity);\n  Future<void> delete(String id);\n}\n```\n\n \n\n**usecases (domain/usecases//):**\n\n \n\nEach usecase = one file, one responsibility:\n\n \n\n```\n// get_<feature>s_usecase.dart\nclass Get<Feature>sUsecase {\n  final <Feature>Repository _repository;\n  Get<Feature>sUsecase(this._repository);\n\n  Future<List<<Feature>>> call() => _repository.getAll();\n}\n\n// create_<feature>_usecase.dart\nclass Create<Feature>Usecase {\n  final <Feature>Repository _repository;\n  Create<Feature>Usecase(this._repository);\n\n  Future<void> call(<Feature> entity) => _repository.create(entity);\n}\n```\n\n \n\n### Data Layer\n\n \n\n**model (data/models/\\_model.dart):**\n\n \n\n```\nimport '../../domain/entities/<feature>.dart';\n\nclass <Feature>Model {\n  final String id;\n  final String name;\n\n  const <Feature>Model({required this.id, required this.name});\n\n  factory <Feature>Model.fromJson(Map<String, dynamic> json) =>\n      <Feature>Model(\n        id:   json['id']   as String,\n        name: json['name'] as String,\n      );\n\n  Map<String, dynamic> toJson() => {'id': id, 'name': name};\n\n  <Feature> toEntity() => <Feature>(id: id, name: name);\n\n  static <Feature>Model fromEntity(<Feature> entity) =>\n      <Feature>Model(id: entity.id, name: entity.name);\n}\n```\n\n \n\n**datasource (data/datasources/\\_datasource.dart):**\n\n \n\n```\nimport 'package:dio/dio.dart';\nimport '../models/<feature>_model.dart';\n\nclass <Feature>Datasource {\n  final Dio _dio;\n  <Feature>Datasource(this._dio);\n\n  Future<List<<Feature>Model>> getAll() async {\n    final response = await _dio.get('/<feature>s');\n    return (response.data as List)\n        .map((e) => <Feature>Model.fromJson(e as Map<String, dynamic>))\n        .toList();\n  }\n\n  Future<<Feature>Model> getById(String id) async {\n    final response = await _dio.get('/<feature>s/$id');\n    return <Feature>Model.fromJson(response.data as Map<String, dynamic>);\n  }\n\n  Future<void> create(<Feature>Model model) async {\n    await _dio.post('/<feature>s', data: model.toJson());\n  }\n\n  Future<void> update(<Feature>Model model) async {\n    await _dio.put('/<feature>s/${model.id}', data: model.toJson());\n  }\n\n  Future<void> delete(String id) async {\n    await _dio.delete('/<feature>s/$id');\n  }\n}\n```\n\n \n\n**repository impl (data/repositories/\\_repository\\_impl.dart):**\n\n \n\n```\nimport '../../domain/entities/<feature>.dart';\nimport '../../domain/repositories/<feature>_repository.dart';\nimport '../datasources/<feature>_datasource.dart';\nimport '../models/<feature>_model.dart';\n\nclass <Feature>RepositoryImpl implements <Feature>Repository {\n  final <Feature>Datasource _dataSource;\n  <Feature>RepositoryImpl(this._dataSource);\n\n  @override\n  Future<List<<Feature>>> getAll() async {\n    final models = await _dataSource.getAll();\n    return models.map((m) => m.toEntity()).toList();\n  }\n\n  @override\n  Future<<Feature>> getById(String id) async {\n    final model = await _dataSource.getById(id);\n    return model.toEntity();\n  }\n\n  @override\n  Future<void> create(<Feature> entity) =>\n      _dataSource.create(<Feature>Model.fromEntity(entity));\n\n  @override\n  Future<void> update(<Feature> entity) =>\n      _dataSource.update(<Feature>Model.fromEntity(entity));\n\n  @override\n  Future<void> delete(String id) => _dataSource.delete(id);\n}\n```\n\n \n\n## When argument is ` audit `\n\n \n\nRead the existing code for ` <feature_name> ` and check:\n\n \n\n1. **Domain isolation**: Do entities import anything from Flutter/Dio/external? (They shouldn't) \n1. **Repository pattern**: Does the datasource return models? Does the repo impl map to entities? \n1. **Usecase single responsibility**: Does each usecase do exactly one thing? \n1. **Dependency direction**: Does data layer depend on domain? (Yes, correct) Does domain depend on data? (No, wrong) \n1. **Model ↔ Entity separation**: Are API models separate from domain entities? \n1. **Exception handling**: Are data-layer exceptions caught and re-thrown as domain exceptions?\n\n \n\nReport findings and fix any violations.\n\n \n\n## Architecture Rules\n\n \n\n1. **Domain layer has zero external dependencies** — pure Dart, no Flutter, no Dio \n1. **Entities use Equatable** — value equality for BLoC state comparisons \n1. **Models handle JSON** — entities never have ` fromJson `/` toJson ` \n1. **Repository interface in domain** — implementation in data \n1. **Usecases are thin** — orchestrate repo calls, no business logic in datasources \n1. **One usecase = one operation** — don't create ` MenuUsecases ` with 5 methods \n1. **Datasources return models** — repositories return entities \n1. **Exceptions**: datasource throws HTTP exceptions, repository catches and rethrows domain exceptions\n\n \n\n## Instructions\n\n \n\n1. Read existing domain/data files before creating new ones \n1. Check ` core/lib/injections.dart ` to see what's already registered \n1. Only create layers that don't exist yet \n1. After scaffolding, run ` /flutter-di ` to register new dependencies \n1. After DI, run ` /flutter-state ` to create the Cubit\n\n \n\n## Files\n\n \n\n- ` LICENSE ` \n- ` SKILL.md ` \n- ` SOURCE.md `\n\n \n\n## Related terms\n\n \n\n- [Flutter](<https://delaparra-services.nl/knowledge-hub/flutter>) \n- [Flutter Clean Architecture](<https://delaparra-services.nl/knowledge-hub/flutter-clean-architecture>)\n\n \n\n## Related services\n\n \n\n- [App development](<https://delaparra-services.nl/services#service-02>) \n- [AI code review](<https://delaparra-services.nl/services#service-05>)\n\n \n\n[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)\n\n[HTML version](https://delaparra-services.nl/skills/flutter-clean-arch)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#webpage",
                "url": "https://delaparra-services.nl/skills/flutter-clean-arch",
                "name": "Flutter Clean Arch | DeLaParra Services",
                "description": "Use when creating or auditing the layers of a Flutter feature or package - where a use case, repository, datasource, entity or model belongs; whether domain may import Flutter; whether a dependency between layers is inverted. Triggers on \"where does this go?\" in a feature, or a request for an architecture review.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#breadcrumb"
                }
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Flutter Clean Arch"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "SoftwareSourceCode",
                "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#skill",
                "url": "https://delaparra-services.nl/skills/flutter-clean-arch",
                "name": "Flutter Clean Arch",
                "description": "Use when creating or auditing the layers of a Flutter feature or package - where a use case, repository, datasource, entity or model belongs; whether domain may import Flutter; whether a dependency between layers is inverted. Triggers on \"where does this go?\" in a feature, or a request for an architecture review.",
                "inLanguage": "en",
                "license": "https://spdx.org/licenses/MIT.html",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#dataset",
                "name": "Flutter Clean Arch",
                "description": "Use when creating or auditing the layers of a Flutter feature or package - where a use case, repository, datasource, entity or model belongs; whether domain may import Flutter; whether a dependency between layers is inverted. Triggers on \"where does this go?\" in a feature, or a request for an architecture review.",
                "url": "https://delaparra-services.nl/skills/flutter-clean-arch",
                "identifier": "https://delaparra-services.nl/skills/flutter-clean-arch#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/skills/flutter-clean-arch#skill"
                },
                "creditText": "gabuldev/flutter-skills",
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://spdx.org/licenses/MIT.html",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "dateModified": "2026-11-30T13:17:19+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#skills",
                    "name": "Skills for AI coding assistants",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "flutter-clean-arch.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-clean-arch.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-clean-arch.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-clean-arch.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-clean-arch.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-clean-arch.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-clean-arch.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-clean-arch.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-clean-arch.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-clean-arch.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-clean-arch-files.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-clean-arch/download",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    }
                ]
            }
        ]
    }
}