@appiq/flutter-workflow 1.4.3 → 2.1.0
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.
- package/CHANGELOG.md +160 -0
- package/README.md +69 -9
- package/agents/claude/cubit-agent.md +164 -2
- package/agents/claude/data-agent.md +163 -2
- package/agents/claude/domain-agent.md +164 -2
- package/agents/claude/feature-manager.md +361 -22
- package/agents/claude/integration-validator.md +1 -0
- package/agents/claude/po-agent.md +1 -0
- package/agents/claude/security-agent.md +163 -2
- package/agents/claude/test-agent.md +165 -2
- package/agents/claude/ui-agent.md +159 -8
- package/config/agent-coordination.json +335 -0
- package/config/independent-mode-template.md +202 -0
- package/lib/independent-agent-tracker.js +565 -0
- package/lib/setup-independent-mode.js +562 -0
- package/lib/state-manager.js +526 -0
- package/package.json +4 -2
- package/templates/enhanced-task-breakdown-template.md +415 -0
- package/templates/enhanced-task-history-template.md +605 -0
- package/templates/feature-template.md +116 -30
- package/templates/additional_cubit_req.md +0 -357
- package/templates/additional_data_req.md +0 -480
- package/templates/additional_domain_req.md +0 -431
- package/templates/additional_ui_req.md +0 -205
- package/templates/feature-history-template.md +0 -280
- package/templates/platform-adaptive-widget-template.dart +0 -407
- package/templates/pretty-ui-examples.md +0 -597
- package/templates/task-breakdown-template.md +0 -265
- package/templates/task-history-template.md +0 -276
|
@@ -1,81 +1,167 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: {
|
|
3
|
-
ui: open
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
name: ${FEATURE_NAME}
|
|
3
|
+
ui: ${UI_STATUS:open}
|
|
4
|
+
cubit: ${CUBIT_STATUS:open}
|
|
5
|
+
domain: ${DOMAIN_STATUS:open}
|
|
6
|
+
data: ${DATA_STATUS:open}
|
|
7
|
+
security: ${SECURITY_STATUS:open}
|
|
8
|
+
test: ${TEST_STATUS:open}
|
|
9
|
+
integration: ${INTEGRATION_STATUS:open}
|
|
10
|
+
status: ${OVERALL_STATUS:open}
|
|
11
|
+
created: ${CREATED_DATE}
|
|
12
|
+
updated: ${UPDATED_DATE}
|
|
13
|
+
completion: ${COMPLETION_PERCENTAGE:0}%
|
|
14
|
+
current_agent: ${CURRENT_AGENT:none}
|
|
15
|
+
current_phase: ${CURRENT_PHASE:initialization}
|
|
11
16
|
---
|
|
12
17
|
|
|
13
|
-
# {
|
|
18
|
+
# ${FEATURE_NAME} - Flutter Feature Development
|
|
14
19
|
|
|
15
|
-
##
|
|
16
|
-
|
|
20
|
+
## 📊 Current Status
|
|
21
|
+
- **Overall Progress**: ${COMPLETION_PERCENTAGE:0}% Complete
|
|
22
|
+
- **Current Phase**: ${CURRENT_PHASE:initialization}
|
|
23
|
+
- **Active Agent**: ${CURRENT_AGENT:none}
|
|
24
|
+
- **Last Updated**: ${UPDATED_DATE}
|
|
17
25
|
|
|
18
|
-
##
|
|
19
|
-
|
|
26
|
+
## 🎯 Feature Description
|
|
27
|
+
${FEATURE_DESCRIPTION:Describe your feature here. This will be analyzed by the PO Agent to create detailed tasks and planning.}
|
|
20
28
|
|
|
21
|
-
##
|
|
29
|
+
## 👤 User Story
|
|
30
|
+
${USER_STORY:As a [user type], I want [functionality] so that [benefit].}
|
|
31
|
+
|
|
32
|
+
## 📋 Requirements
|
|
33
|
+
${REQUIREMENTS_LIST:
|
|
22
34
|
- [ ] Functional requirement 1
|
|
23
35
|
- [ ] Functional requirement 2
|
|
24
36
|
- [ ] Functional requirement 3
|
|
25
37
|
- [ ] Non-functional requirement 1
|
|
26
38
|
- [ ] Non-functional requirement 2
|
|
39
|
+
}
|
|
27
40
|
|
|
28
|
-
## Acceptance Criteria
|
|
41
|
+
## ✅ Acceptance Criteria
|
|
42
|
+
${ACCEPTANCE_CRITERIA:
|
|
29
43
|
- [ ] Given [context], when [action], then [expected result]
|
|
30
44
|
- [ ] Given [context], when [action], then [expected result]
|
|
31
45
|
- [ ] Given [context], when [action], then [expected result]
|
|
46
|
+
}
|
|
32
47
|
|
|
33
|
-
## Technical
|
|
48
|
+
## 🏗️ Technical Specifications
|
|
49
|
+
${TECHNICAL_NOTES:
|
|
34
50
|
- Add any technical considerations
|
|
35
51
|
- Architecture requirements
|
|
36
52
|
- Dependencies on other features
|
|
37
53
|
- Performance requirements
|
|
38
54
|
- Security considerations
|
|
55
|
+
}
|
|
39
56
|
|
|
40
|
-
## UI/UX Requirements
|
|
57
|
+
## 🎨 UI/UX Requirements
|
|
58
|
+
${UI_REQUIREMENTS:
|
|
41
59
|
- Screen designs and layouts
|
|
42
60
|
- User interaction patterns
|
|
43
61
|
- Responsive design requirements
|
|
44
62
|
- Accessibility requirements
|
|
45
63
|
- Animation and transition needs
|
|
64
|
+
}
|
|
46
65
|
|
|
47
|
-
## Data Requirements
|
|
66
|
+
## 📊 Data Requirements
|
|
67
|
+
${DATA_REQUIREMENTS:
|
|
48
68
|
- Data models and entities needed
|
|
49
69
|
- API endpoints required
|
|
50
70
|
- Local storage needs
|
|
51
71
|
- Caching strategies
|
|
52
72
|
- Offline functionality requirements
|
|
73
|
+
}
|
|
53
74
|
|
|
54
|
-
## Security Requirements
|
|
75
|
+
## 🔒 Security Requirements
|
|
76
|
+
${SECURITY_REQUIREMENTS:
|
|
55
77
|
- Authentication needs
|
|
56
78
|
- Authorization requirements
|
|
57
79
|
- Data encryption needs
|
|
58
80
|
- COPPA compliance requirements
|
|
59
81
|
- Privacy considerations
|
|
82
|
+
}
|
|
60
83
|
|
|
61
|
-
## Testing Requirements
|
|
84
|
+
## 🧪 Testing Requirements
|
|
85
|
+
${TESTING_REQUIREMENTS:
|
|
62
86
|
- Unit test scenarios
|
|
63
87
|
- Widget test requirements
|
|
64
88
|
- Integration test flows
|
|
65
89
|
- Performance test criteria
|
|
66
90
|
- Security test requirements
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
## 📈 Agent Progress Overview
|
|
94
|
+
|
|
95
|
+
### 📋 PO Agent (Phoenix) - Requirements Analysis
|
|
96
|
+
**Status**: ${PO_STATUS:pending} | **Progress**: ${PO_PROGRESS:0}%
|
|
97
|
+
**Tasks**: ${PO_TASK_COUNT:0}/5 | **Last Activity**: ${PO_LAST_ACTIVITY:Not started}
|
|
98
|
+
|
|
99
|
+
### 🎨 UI Agent (Aria) - Presentation Layer
|
|
100
|
+
**Status**: ${UI_STATUS:pending} | **Progress**: ${UI_PROGRESS:0}%
|
|
101
|
+
**Tasks**: ${UI_TASK_COUNT:0}/5 | **Last Activity**: ${UI_LAST_ACTIVITY:Not started}
|
|
102
|
+
|
|
103
|
+
### 🔄 Cubit Agent (Sage) - State Management
|
|
104
|
+
**Status**: ${CUBIT_STATUS:pending} | **Progress**: ${CUBIT_PROGRESS:0}%
|
|
105
|
+
**Tasks**: ${CUBIT_TASK_COUNT:0}/5 | **Last Activity**: ${CUBIT_LAST_ACTIVITY:Not started}
|
|
106
|
+
|
|
107
|
+
### 🏗️ Domain Agent (Atlas) - Business Logic
|
|
108
|
+
**Status**: ${DOMAIN_STATUS:pending} | **Progress**: ${DOMAIN_PROGRESS:0}%
|
|
109
|
+
**Tasks**: ${DOMAIN_TASK_COUNT:0}/5 | **Last Activity**: ${DOMAIN_LAST_ACTIVITY:Not started}
|
|
110
|
+
|
|
111
|
+
### 📊 Data Agent (Nova) - Data Layer
|
|
112
|
+
**Status**: ${DATA_STATUS:pending} | **Progress**: ${DATA_PROGRESS:0}%
|
|
113
|
+
**Tasks**: ${DATA_TASK_COUNT:0}/5 | **Last Activity**: ${DATA_LAST_ACTIVITY:Not started}
|
|
114
|
+
|
|
115
|
+
### 🔒 Security Agent (Guardian) - Security & Compliance
|
|
116
|
+
**Status**: ${SECURITY_STATUS:pending} | **Progress**: ${SECURITY_PROGRESS:0}%
|
|
117
|
+
**Tasks**: ${SECURITY_TASK_COUNT:0}/5 | **Last Activity**: ${SECURITY_LAST_ACTIVITY:Not started}
|
|
118
|
+
|
|
119
|
+
### 🧪 Test Agent (Trinity) - Quality Assurance
|
|
120
|
+
**Status**: ${TEST_STATUS:pending} | **Progress**: ${TEST_PROGRESS:0}%
|
|
121
|
+
**Tasks**: ${TEST_TASK_COUNT:0}/5 | **Last Activity**: ${TEST_LAST_ACTIVITY:Not started}
|
|
67
122
|
|
|
68
|
-
|
|
123
|
+
### ✅ Integration Validator - System Integration
|
|
124
|
+
**Status**: ${INTEGRATION_STATUS:pending} | **Progress**: ${INTEGRATION_PROGRESS:0}%
|
|
125
|
+
**Tasks**: ${INTEGRATION_TASK_COUNT:0}/5 | **Last Activity**: ${INTEGRATION_LAST_ACTIVITY:Not started}
|
|
126
|
+
|
|
127
|
+
## 🚦 Quality Gates Status
|
|
128
|
+
|
|
129
|
+
- [ ] **Requirements Gate**: ${QG_REQUIREMENTS:❌ Not Started}
|
|
130
|
+
- [ ] **UI Gate**: ${QG_UI:❌ Not Started}
|
|
131
|
+
- [ ] **State Gate**: ${QG_STATE:❌ Not Started}
|
|
132
|
+
- [ ] **Domain Gate**: ${QG_DOMAIN:❌ Not Started}
|
|
133
|
+
- [ ] **Data Gate**: ${QG_DATA:❌ Not Started}
|
|
134
|
+
- [ ] **Security Gate**: ${QG_SECURITY:❌ Not Started}
|
|
135
|
+
- [ ] **Testing Gate**: ${QG_TESTING:❌ Not Started}
|
|
136
|
+
- [ ] **Integration Gate**: ${QG_INTEGRATION:❌ Not Started}
|
|
137
|
+
|
|
138
|
+
## 🎯 Definition of Done
|
|
69
139
|
- [ ] All acceptance criteria met
|
|
70
|
-
- [ ] UI implementation complete and responsive
|
|
71
|
-
- [ ] State management implemented
|
|
72
|
-
- [ ] Domain logic implemented
|
|
73
|
-
- [ ] Data layer implemented
|
|
74
|
-
- [ ] Security measures implemented
|
|
75
|
-
- [ ] Tests implemented and passing
|
|
140
|
+
- [ ] UI implementation complete and responsive (${UI_PROGRESS:0}%)
|
|
141
|
+
- [ ] State management implemented (${CUBIT_PROGRESS:0}%)
|
|
142
|
+
- [ ] Domain logic implemented (${DOMAIN_PROGRESS:0}%)
|
|
143
|
+
- [ ] Data layer implemented (${DATA_PROGRESS:0}%)
|
|
144
|
+
- [ ] Security measures implemented (${SECURITY_PROGRESS:0}%)
|
|
145
|
+
- [ ] Tests implemented and passing 90%+ coverage (${TEST_PROGRESS:0}%)
|
|
146
|
+
- [ ] Integration validation complete (${INTEGRATION_PROGRESS:0}%)
|
|
76
147
|
- [ ] Documentation updated
|
|
77
148
|
- [ ] Code reviewed and approved
|
|
78
149
|
- [ ] Performance requirements met
|
|
150
|
+
- [ ] COPPA compliance verified
|
|
151
|
+
|
|
152
|
+
## 🔄 Parallel Execution Opportunities
|
|
153
|
+
${PARALLEL_OPPORTUNITIES:None identified yet}
|
|
154
|
+
|
|
155
|
+
## 🚨 Current Blockers
|
|
156
|
+
${CURRENT_BLOCKERS:None}
|
|
157
|
+
|
|
158
|
+
## 📝 Notes & Assumptions
|
|
159
|
+
${ADDITIONAL_NOTES:Additional notes, assumptions, or constraints.}
|
|
160
|
+
|
|
161
|
+
---
|
|
79
162
|
|
|
80
|
-
|
|
81
|
-
|
|
163
|
+
**🤖 Managed by FeatureMaster** | **📄 Auto-updated by AppIQ Workflow System**
|
|
164
|
+
**📞 Commands**: Use `*help` with FeatureMaster for available commands
|
|
165
|
+
**💾 State File**: `docs/features/${FEATURE_NAME}_state.json`
|
|
166
|
+
**📋 Tasks**: `docs/tasks/${FEATURE_NAME}_tasks.md`
|
|
167
|
+
**📈 History**: `docs/tasks/${FEATURE_NAME}_history.md`
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
# Additional Cubit Requirements - State Management Integration
|
|
2
|
-
|
|
3
|
-
This template defines additional state management requirements, provider setup, and integration patterns for your feature.
|
|
4
|
-
|
|
5
|
-
## State Management Architecture
|
|
6
|
-
|
|
7
|
-
### Cubit Integration Pattern
|
|
8
|
-
```dart
|
|
9
|
-
// Feature-specific state management structure
|
|
10
|
-
lib/features/{feature}/presentation/cubit/
|
|
11
|
-
├── {feature}_cubit.dart // Main cubit implementation
|
|
12
|
-
├── {feature}_state.dart // State definitions
|
|
13
|
-
└── {feature}_event.dart // Events (if using BLoC pattern)
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### Global State Dependencies
|
|
17
|
-
- [ ] Authentication state integration
|
|
18
|
-
- [ ] User role state management
|
|
19
|
-
- [ ] Theme/settings state access
|
|
20
|
-
- [ ] Navigation state coordination
|
|
21
|
-
- [ ] Network connectivity state
|
|
22
|
-
- [ ] Offline/online state management
|
|
23
|
-
|
|
24
|
-
## Provider Setup Requirements
|
|
25
|
-
|
|
26
|
-
### Main App Provider Configuration
|
|
27
|
-
```dart
|
|
28
|
-
// Add to main.dart MultiBlocProvider
|
|
29
|
-
MultiBlocProvider(
|
|
30
|
-
providers: [
|
|
31
|
-
// Existing providers...
|
|
32
|
-
BlocProvider<{Feature}Cubit>(
|
|
33
|
-
create: (context) => GetIt.instance<{Feature}Cubit>(),
|
|
34
|
-
),
|
|
35
|
-
// Additional feature dependencies...
|
|
36
|
-
],
|
|
37
|
-
child: MyApp(),
|
|
38
|
-
)
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Dependency Injection Setup
|
|
42
|
-
```dart
|
|
43
|
-
// Add to dependency injection configuration
|
|
44
|
-
void configureDependencies() {
|
|
45
|
-
// Repository registration
|
|
46
|
-
getIt.registerLazySingleton<{Feature}Repository>(
|
|
47
|
-
() => {Feature}RepositoryImpl(
|
|
48
|
-
remoteDataSource: getIt(),
|
|
49
|
-
localDataSource: getIt(),
|
|
50
|
-
networkInfo: getIt(),
|
|
51
|
-
),
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
// Use case registration
|
|
55
|
-
getIt.registerLazySingleton(() => Get{Feature}UseCase(getIt()));
|
|
56
|
-
getIt.registerLazySingleton(() => Create{Feature}UseCase(getIt()));
|
|
57
|
-
getIt.registerLazySingleton(() => Update{Feature}UseCase(getIt()));
|
|
58
|
-
getIt.registerLazySingleton(() => Delete{Feature}UseCase(getIt()));
|
|
59
|
-
|
|
60
|
-
// Cubit registration
|
|
61
|
-
getIt.registerFactory<{Feature}Cubit>(
|
|
62
|
-
() => {Feature}Cubit(
|
|
63
|
-
get{Feature}UseCase: getIt(),
|
|
64
|
-
create{Feature}UseCase: getIt(),
|
|
65
|
-
update{Feature}UseCase: getIt(),
|
|
66
|
-
delete{Feature}UseCase: getIt(),
|
|
67
|
-
),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## State Initialization Requirements
|
|
73
|
-
|
|
74
|
-
### Initial State Setup
|
|
75
|
-
```dart
|
|
76
|
-
class {Feature}Cubit extends Cubit<{Feature}State> {
|
|
77
|
-
{Feature}Cubit({
|
|
78
|
-
required this.get{Feature}UseCase,
|
|
79
|
-
required this.create{Feature}UseCase,
|
|
80
|
-
required this.update{Feature}UseCase,
|
|
81
|
-
required this.delete{Feature}UseCase,
|
|
82
|
-
}) : super(const {Feature}State.initial());
|
|
83
|
-
|
|
84
|
-
// Initialize feature data on cubit creation
|
|
85
|
-
Future<void> initialize() async {
|
|
86
|
-
emit(state.copyWith(status: {Feature}Status.loading));
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
final result = await get{Feature}UseCase.call(NoParams());
|
|
90
|
-
result.fold(
|
|
91
|
-
(failure) => emit(state.copyWith(
|
|
92
|
-
status: {Feature}Status.error,
|
|
93
|
-
errorMessage: failure.message,
|
|
94
|
-
)),
|
|
95
|
-
(data) => emit(state.copyWith(
|
|
96
|
-
status: {Feature}Status.loaded,
|
|
97
|
-
items: data,
|
|
98
|
-
)),
|
|
99
|
-
);
|
|
100
|
-
} catch (e) {
|
|
101
|
-
emit(state.copyWith(
|
|
102
|
-
status: {Feature}Status.error,
|
|
103
|
-
errorMessage: 'Unexpected error occurred',
|
|
104
|
-
));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Widget Integration Pattern
|
|
111
|
-
```dart
|
|
112
|
-
class {Feature}Page extends StatefulWidget {
|
|
113
|
-
@override
|
|
114
|
-
_State createState() => _State();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class _State extends State<{Feature}Page> {
|
|
118
|
-
late {Feature}Cubit cubit;
|
|
119
|
-
|
|
120
|
-
@override
|
|
121
|
-
void initState() {
|
|
122
|
-
super.initState();
|
|
123
|
-
cubit = context.read<{Feature}Cubit>();
|
|
124
|
-
// Initialize cubit data
|
|
125
|
-
cubit.initialize();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@override
|
|
129
|
-
Widget build(BuildContext context) {
|
|
130
|
-
return BlocConsumer<{Feature}Cubit, {Feature}State>(
|
|
131
|
-
listener: (context, state) {
|
|
132
|
-
// Handle side effects (navigation, snackbars, etc.)
|
|
133
|
-
if (state.status == {Feature}Status.error) {
|
|
134
|
-
ScaffoldMessenger.of(context).showSnackBar(
|
|
135
|
-
SnackBar(content: Text(state.errorMessage ?? 'Error occurred')),
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
builder: (context, state) {
|
|
140
|
-
return Scaffold(
|
|
141
|
-
body: _buildBody(state),
|
|
142
|
-
);
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Common Integration Issues & Solutions
|
|
150
|
-
|
|
151
|
-
### Issue 1: Cubit Not Initialized
|
|
152
|
-
**Problem**: `BlocProvider.of() called with a context that does not contain a Cubit`
|
|
153
|
-
**Solution**:
|
|
154
|
-
```dart
|
|
155
|
-
// Ensure proper provider hierarchy
|
|
156
|
-
MaterialApp(
|
|
157
|
-
home: MultiBlocProvider(
|
|
158
|
-
providers: [
|
|
159
|
-
BlocProvider<{Feature}Cubit>(
|
|
160
|
-
create: (context) => GetIt.instance<{Feature}Cubit>(),
|
|
161
|
-
),
|
|
162
|
-
],
|
|
163
|
-
child: {Feature}Page(),
|
|
164
|
-
),
|
|
165
|
-
)
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Issue 2: Duplicate Cubit Registration
|
|
169
|
-
**Problem**: Multiple registrations of the same cubit type
|
|
170
|
-
**Solution**:
|
|
171
|
-
```dart
|
|
172
|
-
// Use registerFactory for cubits (new instance per request)
|
|
173
|
-
getIt.registerFactory<{Feature}Cubit>(() => {Feature}Cubit(...));
|
|
174
|
-
|
|
175
|
-
// Or check if already registered
|
|
176
|
-
if (!getIt.isRegistered<{Feature}Cubit>()) {
|
|
177
|
-
getIt.registerFactory<{Feature}Cubit>(() => {Feature}Cubit(...));
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Issue 3: State Not Persisting Across Navigation
|
|
182
|
-
**Problem**: State resets when navigating between screens
|
|
183
|
-
**Solution**:
|
|
184
|
-
```dart
|
|
185
|
-
// Use singleton registration for state that should persist
|
|
186
|
-
getIt.registerLazySingleton<{Feature}Cubit>(() => {Feature}Cubit(...));
|
|
187
|
-
|
|
188
|
-
// Or use global provider at app level
|
|
189
|
-
class MyApp extends StatelessWidget {
|
|
190
|
-
@override
|
|
191
|
-
Widget build(BuildContext context) {
|
|
192
|
-
return MultiBlocProvider(
|
|
193
|
-
providers: [
|
|
194
|
-
BlocProvider<{Feature}Cubit>(
|
|
195
|
-
create: (context) => GetIt.instance<{Feature}Cubit>(),
|
|
196
|
-
),
|
|
197
|
-
],
|
|
198
|
-
child: MaterialApp(...),
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Cross-Feature State Communication
|
|
205
|
-
|
|
206
|
-
### Feature-to-Feature State Updates
|
|
207
|
-
```dart
|
|
208
|
-
class {Feature}Cubit extends Cubit<{Feature}State> {
|
|
209
|
-
final AuthenticationCubit authCubit;
|
|
210
|
-
final UserRoleCubit userRoleCubit;
|
|
211
|
-
late StreamSubscription authSubscription;
|
|
212
|
-
|
|
213
|
-
{Feature}Cubit({
|
|
214
|
-
required this.authCubit,
|
|
215
|
-
required this.userRoleCubit,
|
|
216
|
-
// ... other dependencies
|
|
217
|
-
}) : super(const {Feature}State.initial()) {
|
|
218
|
-
// Listen to authentication changes
|
|
219
|
-
authSubscription = authCubit.stream.listen((authState) {
|
|
220
|
-
if (authState is! AuthenticatedState) {
|
|
221
|
-
// Clear feature data on logout
|
|
222
|
-
emit(const {Feature}State.initial());
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
@override
|
|
228
|
-
Future<void> close() {
|
|
229
|
-
authSubscription.cancel();
|
|
230
|
-
return super.close();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Global State Access Pattern
|
|
236
|
-
```dart
|
|
237
|
-
// Access other cubits from within a cubit
|
|
238
|
-
void updateBasedOnUserRole() {
|
|
239
|
-
final userRole = userRoleCubit.state.role;
|
|
240
|
-
|
|
241
|
-
switch (userRole) {
|
|
242
|
-
case UserRole.admin:
|
|
243
|
-
loadAdminData();
|
|
244
|
-
break;
|
|
245
|
-
case UserRole.manager:
|
|
246
|
-
loadManagerData();
|
|
247
|
-
break;
|
|
248
|
-
case UserRole.user:
|
|
249
|
-
loadUserData();
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## Performance Optimization
|
|
256
|
-
|
|
257
|
-
### Selective State Updates
|
|
258
|
-
```dart
|
|
259
|
-
// Use copyWith efficiently to avoid unnecessary rebuilds
|
|
260
|
-
emit(state.copyWith(
|
|
261
|
-
status: {Feature}Status.loading,
|
|
262
|
-
// Only update changed fields
|
|
263
|
-
));
|
|
264
|
-
|
|
265
|
-
// Use state comparison to prevent duplicate emissions
|
|
266
|
-
void updateItems(List<{Entity}> newItems) {
|
|
267
|
-
if (!listEquals(state.items, newItems)) {
|
|
268
|
-
emit(state.copyWith(items: newItems));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Memory Management
|
|
274
|
-
```dart
|
|
275
|
-
class {Feature}Cubit extends Cubit<{Feature}State> {
|
|
276
|
-
final List<StreamSubscription> _subscriptions = [];
|
|
277
|
-
|
|
278
|
-
void addSubscription(StreamSubscription subscription) {
|
|
279
|
-
_subscriptions.add(subscription);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
@override
|
|
283
|
-
Future<void> close() {
|
|
284
|
-
// Cancel all subscriptions
|
|
285
|
-
for (final subscription in _subscriptions) {
|
|
286
|
-
subscription.cancel();
|
|
287
|
-
}
|
|
288
|
-
_subscriptions.clear();
|
|
289
|
-
return super.close();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
## Testing Integration
|
|
295
|
-
|
|
296
|
-
### Cubit Testing Setup
|
|
297
|
-
```dart
|
|
298
|
-
// Test setup with proper mocking
|
|
299
|
-
class MockAuthCubit extends MockCubit<AuthState> implements AuthCubit {}
|
|
300
|
-
class MockUserRoleCubit extends MockCubit<UserRoleState> implements UserRoleCubit {}
|
|
301
|
-
|
|
302
|
-
void main() {
|
|
303
|
-
late {Feature}Cubit cubit;
|
|
304
|
-
late MockAuthCubit mockAuthCubit;
|
|
305
|
-
late MockUserRoleCubit mockUserRoleCubit;
|
|
306
|
-
|
|
307
|
-
setUp(() {
|
|
308
|
-
mockAuthCubit = MockAuthCubit();
|
|
309
|
-
mockUserRoleCubit = MockUserRoleCubit();
|
|
310
|
-
|
|
311
|
-
cubit = {Feature}Cubit(
|
|
312
|
-
authCubit: mockAuthCubit,
|
|
313
|
-
userRoleCubit: mockUserRoleCubit,
|
|
314
|
-
// ... other dependencies
|
|
315
|
-
);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
tearDown(() {
|
|
319
|
-
cubit.close();
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
## Integration Checklist
|
|
325
|
-
|
|
326
|
-
### Provider Setup
|
|
327
|
-
- [ ] Cubit registered in dependency injection
|
|
328
|
-
- [ ] Provider added to MultiBlocProvider
|
|
329
|
-
- [ ] Dependencies properly injected
|
|
330
|
-
- [ ] Initialization logic implemented
|
|
331
|
-
|
|
332
|
-
### State Management
|
|
333
|
-
- [ ] Initial state properly defined
|
|
334
|
-
- [ ] State transitions implemented
|
|
335
|
-
- [ ] Error handling added
|
|
336
|
-
- [ ] Loading states managed
|
|
337
|
-
|
|
338
|
-
### Cross-Feature Integration
|
|
339
|
-
- [ ] Authentication state integration
|
|
340
|
-
- [ ] User role state access
|
|
341
|
-
- [ ] Global state dependencies resolved
|
|
342
|
-
- [ ] Navigation state coordination
|
|
343
|
-
|
|
344
|
-
### Performance & Memory
|
|
345
|
-
- [ ] Efficient state updates implemented
|
|
346
|
-
- [ ] Memory leaks prevented (subscriptions canceled)
|
|
347
|
-
- [ ] Unnecessary rebuilds minimized
|
|
348
|
-
- [ ] State persistence strategy defined
|
|
349
|
-
|
|
350
|
-
### Testing
|
|
351
|
-
- [ ] Unit tests for cubit logic
|
|
352
|
-
- [ ] Integration tests with providers
|
|
353
|
-
- [ ] Mock implementations for dependencies
|
|
354
|
-
- [ ] Error scenario testing
|
|
355
|
-
|
|
356
|
-
## Notes
|
|
357
|
-
Add any feature-specific state management requirements, custom integration patterns, or special initialization needs.
|