2.6 KiB
2.6 KiB
Frontend Development Guidelines (Flutter App)
Scope:
apps/**(Flutter mobile app). This index links to project-grounded guidelines only.
Practical Conventions (Quick Rules)
- Keep
apps/libsecond-level layout stable:app/,core/,data/,features/,shared/,l10n/. - Use feature-bounded modules under
features/<domain>/...and keep shared infra indata/+core/. - Parse backend errors as RFC7807 (
code/params) and keep mapping synced with protocol docs. - Prefer shared UI widgets (
shared/widgets/**) and design tokens (AppSpacing/AppRadius+Theme.colorScheme).
Repository Evidence (entry files to read first)
apps/lib/main.dart- bootstrap entry (configureDependencies,Env.init,runApp)apps/lib/app/app.dart- app shell + theme + auth lifecycle orchestrationapps/lib/app/di/injection.dart- DI registration and cross-feature singleton wiringapps/AGENTS.md- enforced frontend domain rules
Real File Path Examples
apps/lib/main.dartapps/lib/app/di/injection.dartapps/lib/data/network/error_code_mapper.dart
Guidelines Index
| Guide | Focus |
|---|---|
| Directory Structure | Module boundaries and placement rules |
| Component Guidelines | Widget composition, shared components, design system usage |
| Hook Guidelines (Bloc/Cubit State Flows) | Flutter state flow conventions using Bloc/Cubit |
| Type Safety | DTO parsing, API boundary typing, protocol alignment |
| Quality Guidelines | Lint/test/logging expectations and review checklist |
Anti-patterns Observed (do not copy)
- Silent/weak failure branches still exist in some paths and should not be expanded:
apps/lib/app/di/injection.dart(setRefreshCallbackcatch branch returnsfalsewithout logging)apps/lib/core/chat/ag_ui_service.dart(malformed SSE payload catch branch intentionally ignores parse error)
- Directly hardcoding API contract assumptions outside protocol docs/mappers leads to drift:
- Keep
docs/protocols/common/http-error-codes.mdandapps/lib/data/network/error_code_mapper.dartsynchronized.
- Keep
Uncertainties / Gaps
- The frontend workflow doc (
.trellis/workflow.md) still uses the historical filenamehook-guidelines.md; this index keeps the filename for compatibility while the content is Flutter Bloc/Cubit specific. - There is no repository-level automated check yet proving every protocol-code change updates all three sides (backend + protocol docs + frontend mapping); this is currently review-driven.