skills/flutter/flutter-architecture/SKILL.md
Enforce Clean Architecture with BLoC pattern for Flutter applications. Use when scaffolding features, structuring data/domain/presentation layers, defining data models, or integrating native platform channels.
npx skillsauth add dhruvanbhalara/skills flutter-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
domain layer must be pure Dart. NO package:flutter imports.Presentation -> Domain <- Data. Data layer implements Domain interfaces.DataSources (External/Raw) vs Repositories (Domain abstraction).featureA/bloc, featureA/models, featureA/views)core directorycore/views/widgets by typeAPI Layer (ItemApiModel)
Domain Layer (Item)
UI Layer (ItemUiState)
UI Event → BLoC (emit Loading) → Repository → DataSource (API/SDK)
↓
Response → Repository (map to Domain Entity) → BLoC (emit Success/Error) → UI
sealed class for domain failures to enable exhaustive pattern matching across layers.(String name, int age)).if (value case final v?) over if (value != null) for null checking with binding.final, interface, base, and sealed class modifiers to express API intent.Either<Failure, T> or Result<T> sealed classes. NEVER throw exceptions across layer boundaries.switch expressions in UI and BLoCs.MethodChannel for one-off calls to native code (e.g., reading device info, triggering native APIs)EventChannel for continuous streams from native to Flutter (e.g., sensor data, connectivity changes)platform/ directory within the relevant featurestatic const channel = MethodChannel('com.app.feature/method')MethodChannel directly from BLoC or UIMissingPluginException gracefully for platforms that don't implement the channeldefaultTargetPlatform checks to guard platform-specific behaviordart:ffi for performance-critical native C/C++ codePlatform.isAndroid / Platform.isIOS for runtime checks (import dart:io)kIsWeb from package:flutter/foundation.dartSwitch.adaptive, Slider.adaptive) over manual platform checks where possibledynamic. Use Object? or explicit types.if (user == null) return;) to reduce nesting and improve readability.TextEditingController, ScrollController, FocusNode, StreamSubscription, AnimationController, etc., MUST be late initialized in initState() and disposed in dispose().print(). Use AppLogger for all logging.core/views/widgets or utilities.///) comments.Follow this sequential workflow when adding a new feature to the application. Copy the checklist to track progress.
BlocBuilder or BlocConsumer to listen to state changes.injectable).development
Perform REST API networking operations (GET, POST, PUT, DELETE) using the lightweight and robust standard `http` package, including platform configurations and background parsing models.
development
Configure internationalization and localization support using Flutter's built-in l10n system, App Resource Bundle (ARB) files, and ICU formatting syntax.
development
Create model classes with fromJson/toJson using dart:convert and Dart 3 pattern matching. Use when manually mapping JSON to classes, parsing HTTP responses, or choosing between manual and code-generated serialization.
data-ai
Diagnose and fix Flutter layout constraint violations (RenderFlex overflow, unbounded height/width, ParentData misuse). Use when encountering layout exceptions, yellow-black overflow stripes, or red error screens.