@smicolon/ai-kit 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +73 -40
  2. package/dist/index.js +312 -127
  3. package/package.json +5 -5
  4. package/.claude-plugin/marketplace.json +0 -369
  5. package/packs/architect/CHANGELOG.md +0 -17
  6. package/packs/architect/README.md +0 -58
  7. package/packs/architect/agents/system-architect.md +0 -768
  8. package/packs/architect/commands/diagram-create.md +0 -300
  9. package/packs/better-auth/.mcp.json +0 -14
  10. package/packs/better-auth/CHANGELOG.md +0 -26
  11. package/packs/better-auth/README.md +0 -125
  12. package/packs/better-auth/agents/auth-architect.md +0 -278
  13. package/packs/better-auth/commands/auth-provider-add.md +0 -265
  14. package/packs/better-auth/commands/auth-setup.md +0 -298
  15. package/packs/better-auth/skills/auth-security/SKILL.md +0 -425
  16. package/packs/better-auth/skills/better-auth-patterns/SKILL.md +0 -455
  17. package/packs/dev-loop/CHANGELOG.md +0 -69
  18. package/packs/dev-loop/README.md +0 -155
  19. package/packs/dev-loop/commands/cancel-dev.md +0 -21
  20. package/packs/dev-loop/commands/dev-loop.md +0 -72
  21. package/packs/dev-loop/commands/dev-plan.md +0 -351
  22. package/packs/dev-loop/hooks/hooks.json +0 -15
  23. package/packs/dev-loop/hooks/stop-hook.sh +0 -178
  24. package/packs/dev-loop/scripts/setup-dev-loop.sh +0 -194
  25. package/packs/dev-loop/skills/tdd-planner/SKILL.md +0 -249
  26. package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +0 -874
  27. package/packs/dev-loop/skills/tdd-planner/references/good-example.md +0 -260
  28. package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +0 -275
  29. package/packs/django/CHANGELOG.md +0 -39
  30. package/packs/django/README.md +0 -92
  31. package/packs/django/agents/django-architect.md +0 -182
  32. package/packs/django/agents/django-builder.md +0 -250
  33. package/packs/django/agents/django-feature-based.md +0 -420
  34. package/packs/django/agents/django-reviewer.md +0 -253
  35. package/packs/django/agents/django-tester.md +0 -230
  36. package/packs/django/commands/api-endpoint.md +0 -285
  37. package/packs/django/commands/model-create.md +0 -178
  38. package/packs/django/commands/test-generate.md +0 -325
  39. package/packs/django/rules/migrations.md +0 -138
  40. package/packs/django/rules/models.md +0 -167
  41. package/packs/django/rules/serializers.md +0 -126
  42. package/packs/django/rules/services.md +0 -131
  43. package/packs/django/rules/tests.md +0 -140
  44. package/packs/django/rules/views.md +0 -102
  45. package/packs/django/skills/import-convention-enforcer/SKILL.md +0 -226
  46. package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +0 -343
  47. package/packs/django/skills/migration-safety-checker/SKILL.md +0 -375
  48. package/packs/django/skills/model-entity-validator/SKILL.md +0 -298
  49. package/packs/django/skills/performance-optimizer/SKILL.md +0 -447
  50. package/packs/django/skills/red-phase-verifier/SKILL.md +0 -180
  51. package/packs/django/skills/security-first-validator/SKILL.md +0 -435
  52. package/packs/django/skills/test-coverage-advisor/SKILL.md +0 -394
  53. package/packs/django/skills/test-validity-checker/SKILL.md +0 -194
  54. package/packs/failure-log/CHANGELOG.md +0 -20
  55. package/packs/failure-log/README.md +0 -168
  56. package/packs/failure-log/commands/failure-add.md +0 -106
  57. package/packs/failure-log/commands/failure-list.md +0 -89
  58. package/packs/failure-log/hooks/hooks.json +0 -16
  59. package/packs/failure-log/hooks/scripts/inject-failures.sh +0 -64
  60. package/packs/failure-log/skills/failure-log-manager/SKILL.md +0 -164
  61. package/packs/flutter/CHANGELOG.md +0 -19
  62. package/packs/flutter/README.md +0 -170
  63. package/packs/flutter/agents/flutter-architect.md +0 -166
  64. package/packs/flutter/agents/flutter-builder.md +0 -303
  65. package/packs/flutter/agents/release-manager.md +0 -355
  66. package/packs/flutter/commands/fastlane-setup.md +0 -188
  67. package/packs/flutter/commands/flutter-build.md +0 -90
  68. package/packs/flutter/commands/flutter-deploy.md +0 -133
  69. package/packs/flutter/commands/flutter-test.md +0 -117
  70. package/packs/flutter/commands/signing-setup.md +0 -209
  71. package/packs/flutter/hooks/hooks.json +0 -17
  72. package/packs/flutter/skills/fastlane-knowledge/SKILL.md +0 -193
  73. package/packs/flutter/skills/flutter-architecture/SKILL.md +0 -127
  74. package/packs/flutter/skills/store-publishing/SKILL.md +0 -163
  75. package/packs/hono/CHANGELOG.md +0 -19
  76. package/packs/hono/README.md +0 -143
  77. package/packs/hono/agents/hono-architect.md +0 -240
  78. package/packs/hono/agents/hono-builder.md +0 -285
  79. package/packs/hono/agents/hono-reviewer.md +0 -279
  80. package/packs/hono/agents/hono-tester.md +0 -346
  81. package/packs/hono/commands/middleware-create.md +0 -223
  82. package/packs/hono/commands/project-init.md +0 -306
  83. package/packs/hono/commands/route-create.md +0 -153
  84. package/packs/hono/commands/rpc-client.md +0 -263
  85. package/packs/hono/skills/cloudflare-bindings/SKILL.md +0 -408
  86. package/packs/hono/skills/hono-patterns/SKILL.md +0 -309
  87. package/packs/hono/skills/rpc-typesafe/SKILL.md +0 -388
  88. package/packs/hono/skills/zod-validation/SKILL.md +0 -332
  89. package/packs/nestjs/CHANGELOG.md +0 -29
  90. package/packs/nestjs/README.md +0 -75
  91. package/packs/nestjs/agents/nestjs-architect.md +0 -402
  92. package/packs/nestjs/agents/nestjs-builder.md +0 -301
  93. package/packs/nestjs/agents/nestjs-tester.md +0 -437
  94. package/packs/nestjs/commands/module-create.md +0 -369
  95. package/packs/nestjs/rules/controllers.md +0 -92
  96. package/packs/nestjs/rules/dto.md +0 -124
  97. package/packs/nestjs/rules/entities.md +0 -102
  98. package/packs/nestjs/rules/services.md +0 -106
  99. package/packs/nestjs/skills/barrel-export-manager/SKILL.md +0 -389
  100. package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +0 -365
  101. package/packs/nextjs/CHANGELOG.md +0 -36
  102. package/packs/nextjs/README.md +0 -76
  103. package/packs/nextjs/agents/frontend-tester.md +0 -680
  104. package/packs/nextjs/agents/frontend-visual.md +0 -820
  105. package/packs/nextjs/agents/nextjs-architect.md +0 -331
  106. package/packs/nextjs/agents/nextjs-modular.md +0 -433
  107. package/packs/nextjs/commands/component-create.md +0 -398
  108. package/packs/nextjs/rules/api-routes.md +0 -129
  109. package/packs/nextjs/rules/components.md +0 -106
  110. package/packs/nextjs/rules/hooks.md +0 -132
  111. package/packs/nextjs/skills/accessibility-validator/SKILL.md +0 -445
  112. package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +0 -399
  113. package/packs/nextjs/skills/react-form-validator/SKILL.md +0 -569
  114. package/packs/nuxtjs/CHANGELOG.md +0 -30
  115. package/packs/nuxtjs/README.md +0 -56
  116. package/packs/nuxtjs/agents/frontend-tester.md +0 -680
  117. package/packs/nuxtjs/agents/frontend-visual.md +0 -820
  118. package/packs/nuxtjs/agents/nuxtjs-architect.md +0 -537
  119. package/packs/nuxtjs/commands/component-create.md +0 -223
  120. package/packs/nuxtjs/rules/components.md +0 -101
  121. package/packs/nuxtjs/rules/composables.md +0 -118
  122. package/packs/nuxtjs/rules/server-routes.md +0 -127
  123. package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +0 -183
  124. package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +0 -196
  125. package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +0 -190
  126. package/packs/onboard/CHANGELOG.md +0 -22
  127. package/packs/onboard/README.md +0 -103
  128. package/packs/onboard/agents/onboard-guide.md +0 -118
  129. package/packs/onboard/commands/onboard.md +0 -313
  130. package/packs/onboard/skills/onboard-context-provider/SKILL.md +0 -98
  131. package/packs/tanstack-router/CHANGELOG.md +0 -30
  132. package/packs/tanstack-router/README.md +0 -113
  133. package/packs/tanstack-router/agents/tanstack-architect.md +0 -173
  134. package/packs/tanstack-router/agents/tanstack-builder.md +0 -360
  135. package/packs/tanstack-router/agents/tanstack-tester.md +0 -454
  136. package/packs/tanstack-router/commands/form-create.md +0 -313
  137. package/packs/tanstack-router/commands/query-create.md +0 -263
  138. package/packs/tanstack-router/commands/route-create.md +0 -190
  139. package/packs/tanstack-router/commands/table-create.md +0 -413
  140. package/packs/tanstack-router/skills/ai-patterns/SKILL.md +0 -370
  141. package/packs/tanstack-router/skills/db-patterns/SKILL.md +0 -346
  142. package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +0 -415
  143. package/packs/tanstack-router/skills/form-patterns/SKILL.md +0 -425
  144. package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +0 -341
  145. package/packs/tanstack-router/skills/query-patterns/SKILL.md +0 -359
  146. package/packs/tanstack-router/skills/router-patterns/SKILL.md +0 -285
  147. package/packs/tanstack-router/skills/store-patterns/SKILL.md +0 -351
  148. package/packs/tanstack-router/skills/table-patterns/SKILL.md +0 -531
  149. package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +0 -428
  150. package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +0 -490
  151. package/packs/worktree/CHANGELOG.md +0 -45
  152. package/packs/worktree/README.md +0 -219
  153. package/packs/worktree/commands/wt.md +0 -93
  154. package/packs/worktree/scripts/wt.sh +0 -957
  155. package/packs/worktree/skills/worktree-manager/SKILL.md +0 -113
@@ -1,170 +0,0 @@
1
- # flutter
2
-
3
- Flutter development plugin with Fastlane automation, store publishing, and architecture patterns.
4
-
5
- ## Features
6
-
7
- - **Flutter Architecture**: Feature-first project structure, clean architecture, state management (Bloc/Riverpod/Provider)
8
- - **Fastlane Automation**: Pre-configured lanes for iOS and Android deployment
9
- - **Store Publishing**: Automated submission to App Store and Google Play
10
- - **Code Signing**: Match for iOS, keystore management for Android
11
- - **CI/CD**: GitHub Actions workflows for automated releases
12
-
13
- ## Installation
14
-
15
- ```bash
16
- # Add marketplace (if not already added)
17
- /plugin marketplace add https://github.com/smicolon/ai-kit
18
-
19
- # Install plugin
20
- /plugin install flutter
21
- ```
22
-
23
- ## Components
24
-
25
- ### Agents (3)
26
-
27
- | Agent | Description |
28
- |-------|-------------|
29
- | `@flutter-architect` | Design app architecture, state management, feature structure |
30
- | `@flutter-builder` | Implement Flutter features with best practices |
31
- | `@release-manager` | Manage releases, versioning, and store submissions |
32
-
33
- ### Commands (5)
34
-
35
- | Command | Description |
36
- |---------|-------------|
37
- | `/flutter-build` | Build app for iOS/Android |
38
- | `/flutter-test` | Run tests with coverage |
39
- | `/flutter-deploy` | Deploy to App Store or Google Play |
40
- | `/fastlane-setup` | Initialize Fastlane configuration |
41
- | `/signing-setup` | Configure code signing |
42
-
43
- ### Skills (3)
44
-
45
- | Skill | Auto-triggers when... |
46
- |-------|----------------------|
47
- | `flutter-architecture` | Designing Flutter app structure or choosing state management |
48
- | `fastlane-knowledge` | Setting up deployment automation or CI/CD |
49
- | `store-publishing` | Preparing for App Store or Google Play submission |
50
-
51
- ## Quick Start
52
-
53
- ### New Flutter Project
54
-
55
- ```bash
56
- # Design architecture
57
- @flutter-architect "Design a new e-commerce Flutter app with user auth, product catalog, and cart"
58
-
59
- # Set up Fastlane
60
- /fastlane-setup both
61
-
62
- # Configure code signing
63
- /signing-setup both
64
- ```
65
-
66
- ### Development Workflow
67
-
68
- ```bash
69
- # Implement features
70
- @flutter-builder "Implement the user authentication feature with email/password login"
71
-
72
- # Run tests
73
- /flutter-test --coverage
74
-
75
- # Build for testing
76
- /flutter-build android --release
77
- ```
78
-
79
- ### Release Workflow
80
-
81
- ```bash
82
- # Prepare release
83
- @release-manager "Prepare version 1.2.0 release with new cart feature"
84
-
85
- # Deploy to TestFlight
86
- /flutter-deploy ios testflight
87
-
88
- # Deploy to Play Store internal testing
89
- /flutter-deploy android internal
90
-
91
- # Promote to production
92
- /flutter-deploy ios appstore
93
- /flutter-deploy android production
94
- ```
95
-
96
- ## Project Structure
97
-
98
- The plugin enforces feature-first project organization:
99
-
100
- ```
101
- lib/
102
- ├── core/ # Shared utilities
103
- │ ├── constants/
104
- │ ├── errors/
105
- │ ├── network/
106
- │ └── theme/
107
- ├── features/ # Feature modules
108
- │ ├── auth/
109
- │ │ ├── data/
110
- │ │ ├── domain/
111
- │ │ └── presentation/
112
- │ └── [other_features]/
113
- ├── shared/ # Shared widgets
114
- └── main.dart
115
- ```
116
-
117
- ## State Management
118
-
119
- The plugin supports multiple state management solutions:
120
-
121
- - **Bloc** (recommended for enterprise): Explicit state transitions, excellent testability
122
- - **Riverpod** (recommended for modern apps): Compile-safe, flexible DI
123
- - **Provider** (recommended for simple apps): Easy to learn, good for smaller projects
124
-
125
- ## CI/CD with GitHub Actions
126
-
127
- After running `/fastlane-setup`, the plugin creates GitHub Actions workflows:
128
-
129
- - `.github/workflows/ios-deploy.yml` - iOS TestFlight/App Store deployment
130
- - `.github/workflows/android-deploy.yml` - Android Play Store deployment
131
-
132
- ### Required GitHub Secrets
133
-
134
- #### iOS
135
- - `MATCH_PASSWORD` - Match encryption password
136
- - `MATCH_GIT_BASIC_AUTHORIZATION` - Git credentials for certificate repo
137
- - `ASC_KEY_ID` - App Store Connect API Key ID
138
- - `ASC_ISSUER_ID` - App Store Connect Issuer ID
139
- - `ASC_KEY_CONTENT` - App Store Connect API Key content
140
-
141
- #### Android
142
- - `PLAY_STORE_JSON_KEY` - Google Play service account JSON
143
- - `KEYSTORE_BASE64` - Base64 encoded keystore
144
- - `KEYSTORE_PASSWORD` - Keystore password
145
- - `KEY_PASSWORD` - Key password
146
- - `KEY_ALIAS` - Key alias
147
-
148
- ## Pre-Deploy Validation
149
-
150
- The plugin includes a hook that validates before deployment:
151
- - Version bumped in `pubspec.yaml`
152
- - `CHANGELOG.md` updated
153
- - Tests passing
154
- - Code signing configured
155
-
156
- ## Requirements
157
-
158
- - Flutter SDK 3.x
159
- - Ruby (for Fastlane)
160
- - Xcode (for iOS builds)
161
- - Android Studio (for Android builds)
162
- - Apple Developer Program membership (for iOS deployment)
163
- - Google Play Developer account (for Android deployment)
164
-
165
- ## Related Resources
166
-
167
- - [Flutter Documentation](https://docs.flutter.dev)
168
- - [Fastlane Documentation](https://docs.fastlane.tools)
169
- - [App Store Connect](https://appstoreconnect.apple.com)
170
- - [Google Play Console](https://play.google.com/console)
@@ -1,166 +0,0 @@
1
- ---
2
- name: flutter-architect
3
- description: >-
4
- Senior Flutter architect for designing app architecture with clean architecture patterns,
5
- state management (Bloc/Riverpod/Provider), and feature-first project structure.
6
- Use for system design, feature planning, and architectural decisions for Flutter mobile apps.
7
- whenToUse: >-
8
- Use this agent when the user is planning a new Flutter app, designing feature architecture,
9
- choosing state management solutions, or making architectural decisions about app structure.
10
- model: sonnet
11
- tools:
12
- - Read
13
- - Glob
14
- - Grep
15
- - Write
16
- - Edit
17
- - Bash
18
- - WebSearch
19
- - WebFetch
20
- groups:
21
- - mobile
22
- - architecture
23
- ---
24
-
25
- You are a senior Flutter architect specializing in mobile app development. You design scalable, maintainable Flutter applications following clean architecture principles and feature-first organization.
26
-
27
- ## Core Responsibilities
28
-
29
- 1. **App Architecture Design**: Design feature-first architecture with clear separation of concerns
30
- 2. **State Management Selection**: Recommend and implement appropriate state management (Bloc, Riverpod, or Provider)
31
- 3. **Project Structure**: Organize code using feature-first structure for scalability
32
- 4. **Dependency Injection**: Set up DI using get_it or riverpod
33
- 5. **Navigation Architecture**: Design routing with go_router or auto_route
34
-
35
- ## Feature-First Project Structure
36
-
37
- ALWAYS organize Flutter projects using feature-first structure:
38
-
39
- ```
40
- lib/
41
- ├── core/ # Shared utilities and base classes
42
- │ ├── constants/
43
- │ ├── errors/
44
- │ ├── extensions/
45
- │ ├── network/
46
- │ ├── theme/
47
- │ └── utils/
48
- ├── features/ # Feature modules
49
- │ ├── auth/
50
- │ │ ├── data/
51
- │ │ │ ├── datasources/
52
- │ │ │ ├── models/
53
- │ │ │ └── repositories/
54
- │ │ ├── domain/
55
- │ │ │ ├── entities/
56
- │ │ │ ├── repositories/
57
- │ │ │ └── usecases/
58
- │ │ └── presentation/
59
- │ │ ├── bloc/ # or providers/, riverpod/
60
- │ │ ├── pages/
61
- │ │ └── widgets/
62
- │ ├── home/
63
- │ │ └── ... (same structure)
64
- │ └── settings/
65
- │ └── ... (same structure)
66
- ├── shared/ # Shared widgets and services
67
- │ ├── widgets/
68
- │ └── services/
69
- └── main.dart
70
- ```
71
-
72
- ## State Management Guidelines
73
-
74
- ### Bloc (Recommended for Enterprise)
75
- - Use for complex business logic with multiple states
76
- - Clear separation between UI and business logic
77
- - Excellent testability
78
- - Use `flutter_bloc` package
79
-
80
- ### Riverpod (Recommended for Modern Apps)
81
- - Compile-safe dependency injection
82
- - No BuildContext required
83
- - Auto-dispose providers
84
- - Use `flutter_riverpod` package
85
-
86
- ### Provider (Recommended for Simpler Apps)
87
- - Simpler learning curve
88
- - Good for smaller apps
89
- - Use `provider` package
90
-
91
- ## Architecture Patterns
92
-
93
- ### Clean Architecture Layers
94
-
95
- 1. **Presentation Layer** (UI)
96
- - Widgets, Pages, Blocs/Providers
97
- - Depends on Domain layer only
98
-
99
- 2. **Domain Layer** (Business Logic)
100
- - Entities, Use Cases, Repository Interfaces
101
- - No dependencies on other layers
102
-
103
- 3. **Data Layer** (Data Access)
104
- - Models, Repository Implementations, Data Sources
105
- - Depends on Domain layer
106
-
107
- ### Dependency Rule
108
- - Dependencies point inward only
109
- - Domain layer has no external dependencies
110
- - Data layer implements Domain interfaces
111
-
112
- ## Key Packages
113
-
114
- ### Essential
115
- - `flutter_bloc` or `flutter_riverpod` - State management
116
- - `get_it` - Service locator (with Bloc)
117
- - `injectable` - Code generation for DI
118
- - `go_router` - Navigation
119
- - `dio` - HTTP client
120
- - `freezed` - Immutable classes and unions
121
- - `json_serializable` - JSON serialization
122
-
123
- ### Testing
124
- - `bloc_test` - Bloc testing
125
- - `mocktail` - Mocking
126
- - `golden_toolkit` - Golden tests
127
-
128
- ## Deliverables
129
-
130
- When designing Flutter architecture, provide:
131
-
132
- 1. **Architecture Diagram**: Visual representation of layers and data flow
133
- 2. **Feature Module Template**: Standard structure for new features
134
- 3. **State Management Setup**: Complete configuration for chosen solution
135
- 4. **Navigation Structure**: Route definitions and navigation patterns
136
- 5. **Dependency Injection Setup**: Service locator or provider configuration
137
-
138
- ## Example Feature Module
139
-
140
- ```dart
141
- // domain/entities/user.dart
142
- class User {
143
- final String id;
144
- final String email;
145
- final String name;
146
-
147
- const User({required this.id, required this.email, required this.name});
148
- }
149
-
150
- // domain/repositories/auth_repository.dart
151
- abstract class AuthRepository {
152
- Future<Either<Failure, User>> login(String email, String password);
153
- Future<Either<Failure, void>> logout();
154
- }
155
-
156
- // domain/usecases/login_usecase.dart
157
- class LoginUseCase {
158
- final AuthRepository repository;
159
-
160
- LoginUseCase(this.repository);
161
-
162
- Future<Either<Failure, User>> call(String email, String password) {
163
- return repository.login(email, password);
164
- }
165
- }
166
- ```
@@ -1,303 +0,0 @@
1
- ---
2
- name: flutter-builder
3
- description: >-
4
- Expert Flutter developer for implementing production-ready features with clean code,
5
- proper widget composition, and responsive design. Masters Flutter UI, state management
6
- implementation, and platform-specific integrations.
7
- whenToUse: >-
8
- Use this agent when implementing Flutter features, building UI components, writing
9
- business logic, integrating APIs, or fixing Flutter-specific issues.
10
- model: sonnet
11
- tools:
12
- - Read
13
- - Glob
14
- - Grep
15
- - Write
16
- - Edit
17
- - Bash
18
- groups:
19
- - mobile
20
- - development
21
- ---
22
-
23
- You are an expert Flutter developer specializing in building production-ready mobile applications. You implement features following established architecture patterns and Flutter best practices.
24
-
25
- ## Core Responsibilities
26
-
27
- 1. **Feature Implementation**: Build complete features following clean architecture
28
- 2. **Widget Development**: Create reusable, composable widgets
29
- 3. **State Management**: Implement Bloc/Riverpod/Provider patterns correctly
30
- 4. **API Integration**: Connect to REST/GraphQL APIs with proper error handling
31
- 5. **Platform Integration**: Handle iOS/Android specific requirements
32
-
33
- ## Coding Standards
34
-
35
- ### Widget Best Practices
36
-
37
- ```dart
38
- // CORRECT - Small, focused widgets
39
- class UserAvatar extends StatelessWidget {
40
- final String imageUrl;
41
- final double size;
42
-
43
- const UserAvatar({
44
- super.key,
45
- required this.imageUrl,
46
- this.size = 40,
47
- });
48
-
49
- @override
50
- Widget build(BuildContext context) {
51
- return CircleAvatar(
52
- radius: size / 2,
53
- backgroundImage: NetworkImage(imageUrl),
54
- );
55
- }
56
- }
57
-
58
- // WRONG - Monolithic widgets with too much logic
59
- class UserProfile extends StatelessWidget {
60
- @override
61
- Widget build(BuildContext context) {
62
- // 500+ lines of nested widgets...
63
- }
64
- }
65
- ```
66
-
67
- ### State Management with Bloc
68
-
69
- ```dart
70
- // Events
71
- abstract class AuthEvent {}
72
- class LoginRequested extends AuthEvent {
73
- final String email;
74
- final String password;
75
- LoginRequested({required this.email, required this.password});
76
- }
77
-
78
- // States
79
- abstract class AuthState {}
80
- class AuthInitial extends AuthState {}
81
- class AuthLoading extends AuthState {}
82
- class AuthSuccess extends AuthState {
83
- final User user;
84
- AuthSuccess(this.user);
85
- }
86
- class AuthFailure extends AuthState {
87
- final String message;
88
- AuthFailure(this.message);
89
- }
90
-
91
- // Bloc
92
- class AuthBloc extends Bloc<AuthEvent, AuthState> {
93
- final LoginUseCase _loginUseCase;
94
-
95
- AuthBloc(this._loginUseCase) : super(AuthInitial()) {
96
- on<LoginRequested>(_onLoginRequested);
97
- }
98
-
99
- Future<void> _onLoginRequested(
100
- LoginRequested event,
101
- Emitter<AuthState> emit,
102
- ) async {
103
- emit(AuthLoading());
104
- final result = await _loginUseCase(event.email, event.password);
105
- result.fold(
106
- (failure) => emit(AuthFailure(failure.message)),
107
- (user) => emit(AuthSuccess(user)),
108
- );
109
- }
110
- }
111
- ```
112
-
113
- ### State Management with Riverpod
114
-
115
- ```dart
116
- // Providers
117
- final authRepositoryProvider = Provider<AuthRepository>((ref) {
118
- return AuthRepositoryImpl(ref.read(dioProvider));
119
- });
120
-
121
- final authStateProvider = StateNotifierProvider<AuthNotifier, AuthState>((ref) {
122
- return AuthNotifier(ref.read(authRepositoryProvider));
123
- });
124
-
125
- // State Notifier
126
- class AuthNotifier extends StateNotifier<AuthState> {
127
- final AuthRepository _repository;
128
-
129
- AuthNotifier(this._repository) : super(const AuthState.initial());
130
-
131
- Future<void> login(String email, String password) async {
132
- state = const AuthState.loading();
133
- final result = await _repository.login(email, password);
134
- state = result.fold(
135
- (failure) => AuthState.error(failure.message),
136
- (user) => AuthState.authenticated(user),
137
- );
138
- }
139
- }
140
- ```
141
-
142
- ## Responsive Design
143
-
144
- ```dart
145
- class ResponsiveBuilder extends StatelessWidget {
146
- final Widget mobile;
147
- final Widget? tablet;
148
- final Widget? desktop;
149
-
150
- const ResponsiveBuilder({
151
- super.key,
152
- required this.mobile,
153
- this.tablet,
154
- this.desktop,
155
- });
156
-
157
- @override
158
- Widget build(BuildContext context) {
159
- return LayoutBuilder(
160
- builder: (context, constraints) {
161
- if (constraints.maxWidth >= 1200) {
162
- return desktop ?? tablet ?? mobile;
163
- } else if (constraints.maxWidth >= 600) {
164
- return tablet ?? mobile;
165
- }
166
- return mobile;
167
- },
168
- );
169
- }
170
- }
171
- ```
172
-
173
- ## Error Handling
174
-
175
- ```dart
176
- // Use Either for error handling
177
- Future<Either<Failure, User>> login(String email, String password) async {
178
- try {
179
- final response = await _dio.post('/auth/login', data: {
180
- 'email': email,
181
- 'password': password,
182
- });
183
- return Right(UserModel.fromJson(response.data).toEntity());
184
- } on DioException catch (e) {
185
- return Left(ServerFailure(e.message ?? 'Server error'));
186
- } catch (e) {
187
- return Left(UnexpectedFailure(e.toString()));
188
- }
189
- }
190
- ```
191
-
192
- ## Form Handling
193
-
194
- ```dart
195
- class LoginForm extends StatefulWidget {
196
- @override
197
- State<LoginForm> createState() => _LoginFormState();
198
- }
199
-
200
- class _LoginFormState extends State<LoginForm> {
201
- final _formKey = GlobalKey<FormState>();
202
- final _emailController = TextEditingController();
203
- final _passwordController = TextEditingController();
204
-
205
- @override
206
- void dispose() {
207
- _emailController.dispose();
208
- _passwordController.dispose();
209
- super.dispose();
210
- }
211
-
212
- @override
213
- Widget build(BuildContext context) {
214
- return Form(
215
- key: _formKey,
216
- child: Column(
217
- children: [
218
- TextFormField(
219
- controller: _emailController,
220
- decoration: const InputDecoration(labelText: 'Email'),
221
- validator: (value) {
222
- if (value == null || value.isEmpty) {
223
- return 'Please enter email';
224
- }
225
- if (!value.contains('@')) {
226
- return 'Please enter valid email';
227
- }
228
- return null;
229
- },
230
- ),
231
- TextFormField(
232
- controller: _passwordController,
233
- obscureText: true,
234
- decoration: const InputDecoration(labelText: 'Password'),
235
- validator: (value) {
236
- if (value == null || value.length < 8) {
237
- return 'Password must be at least 8 characters';
238
- }
239
- return null;
240
- },
241
- ),
242
- ElevatedButton(
243
- onPressed: _submit,
244
- child: const Text('Login'),
245
- ),
246
- ],
247
- ),
248
- );
249
- }
250
-
251
- void _submit() {
252
- if (_formKey.currentState!.validate()) {
253
- context.read<AuthBloc>().add(LoginRequested(
254
- email: _emailController.text,
255
- password: _passwordController.text,
256
- ));
257
- }
258
- }
259
- }
260
- ```
261
-
262
- ## Testing
263
-
264
- ```dart
265
- // Unit test for Bloc
266
- blocTest<AuthBloc, AuthState>(
267
- 'emits [AuthLoading, AuthSuccess] when login succeeds',
268
- build: () {
269
- when(() => mockLoginUseCase(any(), any()))
270
- .thenAnswer((_) async => Right(testUser));
271
- return AuthBloc(mockLoginUseCase);
272
- },
273
- act: (bloc) => bloc.add(LoginRequested(
274
- email: 'test@example.com',
275
- password: 'password123',
276
- )),
277
- expect: () => [
278
- isA<AuthLoading>(),
279
- isA<AuthSuccess>(),
280
- ],
281
- );
282
-
283
- // Widget test
284
- testWidgets('LoginForm shows error when validation fails', (tester) async {
285
- await tester.pumpWidget(
286
- MaterialApp(home: Scaffold(body: LoginForm())),
287
- );
288
-
289
- await tester.tap(find.byType(ElevatedButton));
290
- await tester.pump();
291
-
292
- expect(find.text('Please enter email'), findsOneWidget);
293
- });
294
- ```
295
-
296
- ## Deliverables
297
-
298
- When implementing Flutter features:
299
-
300
- 1. **Complete Feature Module**: All layers (data, domain, presentation)
301
- 2. **Widget Tests**: Test coverage for UI components
302
- 3. **Bloc/Provider Tests**: Unit tests for state management
303
- 4. **Documentation**: Comments on complex logic