Skip to content
Back to skills

Flutter Layer Based Clean Architecture

ASecurity

Put that rule in the **domain layer** as a checkout policy/use case because it is business behavior, not UI behavior. It should operate on domain entities/value objects and return a domain result or `Failure`; it must not depend on Flutter widgets, BLoC, Dio, or a DTO. ```dart // lib/domain/entities/cart.dart @freezed class Cart with _$Cart { const factory Cart({required Money total}) = _Cart; } // lib/domain/entities/customer_credit.dart @freezed class CustomerCredit with _$CustomerCredit { ...

  • 584 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentapi

Works with

  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-layer-based-clean-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter Layer Based Clean Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flutter Layer Based Clean Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-flutter-layer-based-clean-architecture-bb0d3c04/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-layer-based-clean-architecture-bb0d3c04)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
Put that rule in the **domain layer** as a checkout policy/use case because it is business behavior, not UI behavior. It should operate on domain entities/value objects and return a domain result or `Failure`; it must not depend on Flutter widgets, BLoC, Dio, or a DTO.

```dart
// lib/domain/entities/cart.dart
@freezed
class Cart with _$Cart {
  const factory Cart({required Money total}) = _Cart;
}

// lib/domain/entities/customer_credit.dart
@freezed
class CustomerCredit with _$CustomerCredit {
  const factory CustomerCredit({required Money available}) = _CustomerCredit;
}

// lib/domain/failures/checkout_failure.dart
@freezed
sealed class CheckoutFailure with _$CheckoutFailure {
  const factory CheckoutFailure.insufficientCredit({
    required Money required,
    required Money available,
  }) = InsufficientCredit;
}

// lib/domain/usecases/validate_checkout.dart
class ValidateCheckout {
  const ValidateCheckout();

  Either<CheckoutFailure, Unit> call({
    required Cart cart,
    required CustomerCredit credit,
  }) {
    if (cart.total > credit.available) {
      return left(CheckoutFailure.insufficientCredit(
        required: cart.total,
        available: credit.available,
      ));
    }
    return right(unit);
  }
}
```

The application layer's `CheckoutCubit` obtains the cart and credit through domain repository interfaces, invokes `ValidateCheckout`, and converts the result into presentation state (for example, `readyToCheckout` or `creditRejected`). The screen only renders that state and sends the user's checkout action. If available credit comes from an API, its DTO-to-domain mapping belongs in infrastructure before the Cubit calls the domain use case.

Files in this skill

  • eval-1.baseline.md1.3 KB
  • eval-1.with-skill.md2.8 KB
  • eval-2.baseline.md1.4 KB
  • eval-2.with-skill.md2.6 KB
  • eval-3.baseline.md1.5 KB
  • eval-3.with-skill.md1.7 KB
  • trigger-1.md211 B
  • trigger-2.md122 B
  • trigger-3.md166 B
  • trigger-4.md179 B
  • trigger-5.md212 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.