flutter-design-architecture
Design Architecture Skill
Feature Structure (Mandatory)
lib/<features|feature>/<feature>/
data/datasources/<feature>_remote_datasource.dart # @RestApi
dtos/<feature>_dto.dart # @JsonSerializable
repositories/<feature>_repository_impl.dart # @Injectable
domain/models/<feature>.dart # Equatable
repositories/<feature>_repository.dart # Abstract
view/<state_mgmt>/ # bloc/, provider/, getx/, riverpod/
widgets/<feature>_card.dart
<feature>_page.dart
Core Structure
lib/core/
utils/extensions/, helpers/, validators/
widgets/buttons/, cards/, dialogs/
constants/app_constants.dart
enums/app_enums.dart
test/<feature>/data/, domain/, view/
fixtures/<feature>_fixtures.dart
Quick Templates
// Datasource (@RestApi)
abstract class <Feature>RemoteDatasource {
factory <Feature>RemoteDatasource(Dio dio) = _<Feature>RemoteDatasource;
('/api/<endpoint>') Future<<Feature>Dto> fetch();
}
// DTO (@JsonSerializable)
class <Feature>Dto {
final String id;
factory <Feature>Dto.fromJson(Map<String, dynamic> json) => _$<Feature>DtoFromJson(json);
}
// Model (Equatable)
class <Feature> extends Equatable {
final String id;
const <Feature>({required this.id});
List<Object?> get props => [id];
}
// Repository
abstract class <Feature>Repository { Future<<Feature>> fetch(); }
(as: <Feature>Repository)
class <Feature>RepositoryImpl implements <Feature>Repository {
final <Feature>RemoteDatasource _remote;
Future<<Feature>> fetch() async => (await _remote.fetch()).toModel();
}
// State Management (Bloc|ChangeNotifier|GetxController|StateNotifier)
class <Feature>StateManager {
final <Feature>Repository _repository;
// Implement based on chosen state management
}
Error Handling
abstract class AppException implements Exception { final String message; }
// In repository
try { return await _remote.fetch(); }
on DioException catch (e) {
if (e.response?.statusCode == 404) throw NotFoundException();
throw NetworkException();
}
After Scaffolding
flutter pub run build_runner build # Generate *.g.dart
flutter analyze # Must pass (0 errors)
flutter test # Create & run tests
More from desquared/agents-rules-skills
shared-bug-investigation
Scientific method expert for systematic bug investigation and root cause analysis. Use when users report bugs, crashes, unexpected behavior, or debugging requests. Applies hypothesis-driven investigation, controlled experiments, and rigorous validation across any programming language or platform.
23android-performance-profiler
Identifies potential performance bottlenecks in Jetpack Compose code including expensive recompositions, unnecessary redraws, and memory issues. Use when code involves lists, animations, complex UI, or when the user asks about performance optimization.
19ios-swiftui-architecture-review
Analyze SwiftUI view hierarchies and suggest MVVM or other architectural improvements. Use when **reviewing existing SwiftUI code**, creating new SwiftUI components, analyzing view structure, or when the user asks about SwiftUI architecture patterns. Best for code review and refactoring guidance.
13android-compose-architecture-review
Analyze Jetpack Compose UI hierarchies and suggest MVVM/MVI or other architectural improvements. Use when reviewing existing Compose code, creating new Compose components, analyzing composable structure, or when the user asks about Compose architecture patterns. Best for code review and refactoring guidance.
13android-accessibility-validator
Checks and suggests accessibility improvements for Jetpack Compose and Android Views including TalkBack labels, dynamic text support, and color contrast. Use when creating or modifying UI components, screens, or when the user asks about accessibility.
12android-kotlin-api-design-reviewer
Review function and class interfaces for Kotlin Coding Conventions compliance. Use when creating public APIs, reusable components, library interfaces, or when the user asks for API design review or Kotlin naming conventions.
11