A production-ready TODO application built with Flutter using Thomas Burkhart's PFA (Practical Flutter Architecture), featuring reactive state management with watch_it, command pattern with command_it, and local-first storage with Hive.
Phase 1A: β COMPLETE - Foundation & Business Logic Phase 1B: β³ Pending - UI Implementation Phase 2: β³ Planned - Firebase Integration
- rules.md - Complete architecture guidelines and best practices
- plan.md - 22-step implementation plan with milestones
- PHASE1_PROGRESS.md - Detailed completion log for Phase 1
- TEST_SUMMARY.md - Comprehensive test coverage report
This app follows Thomas Burkhart's pragmatic three-layer architecture:
βββββββββββββββββββββββββββββββββββββββ
β Views Layer (UI) β
β - WatchingWidgets with watch_it β
β - Self-responsible pages β
β - Reactive state updates β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Managers Layer (Logic) β
β - Business logic with Commands β
β - ValueNotifiers for state β
β - Validation & coordination β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Services Layer (I/O) β
β - Hive local storage β
β - Firebase (Phase 2) β
β - Pure data transformation β
βββββββββββββββββββββββββββββββββββββββ
- State Management:
watch_itv1.7.0 - Reactive widgets without boilerplate - Command Pattern:
command_itv8.0.0 - Wraps operations with execution state - Dependency Injection:
get_itv8.0.0 - Service locator pattern - Local Storage:
hivev2.2.3 - Fast NoSQL database - ID Generation:
uuidv4.0.0 - Unique identifiers
- Flutter SDK 3.9.0 or higher
- Dart 3.0+ (included with Flutter)
-
Clone the repository
cd todoit -
Install dependencies
flutter pub get
-
Generate code
dart run build_runner build --delete-conflicting-outputs
-
Run the app
# Chrome (recommended for development) flutter run -d chrome # iOS Simulator flutter run -d ios # Android Emulator flutter run -d android
# Run all tests
flutter test
# Run with coverage
flutter test --coverage
# Run specific test file
flutter test test/models/todo_test.dartTest Results: β 69/69 passing (~98% coverage)
lib/
βββ main.dart # App entry point with Hive initialization
βββ locator.dart # Dependency injection setup
βββ features/
β βββ todos/
β β βββ models/
β β β βββ todo.dart # Domain model
β β β βββ todo_dto.dart # Hive DTO
β β β βββ todo_dto.g.dart # Generated Hive adapter
β β βββ managers/
β β β βββ todo_manager.dart # Business logic with Commands
β β βββ views/ # [Phase 1B - TODO]
β β βββ todo_list_view.dart
β β βββ todo_form_view.dart
β βββ settings/
β βββ managers/ # [Phase 1B - TODO]
β βββ views/ # [Phase 1B - TODO]
βββ services/
β βββ storage/
β βββ hive_storage_service.dart # Local storage implementation
βββ shared/
βββ widgets/ # [Phase 1B - TODO]
βββ utils/ # [Phase 1B - TODO]
test/
βββ models/
β βββ todo_test.dart # 17 tests β
βββ services/
β βββ hive_storage_service_test.dart # 24 tests β
βββ managers/
βββ todo_manager_test.dart # 28 tests β
- β Todo CRUD operations (Create, Read, Update, Delete)
- β Toggle todo completion status
- β Filter todos (All / Active / Completed)
- β Clear completed todos
- β Persistent local storage with Hive
- β Automatic sorting (newest first)
- β Input validation (title required)
- β UUID generation for unique IDs
- β Timestamp tracking (created/updated)
- β Reactive state management
- β Command pattern for operations
- β³ Todo list view with filters
- β³ Add/Edit todo form
- β³ Swipe to delete
- β³ Dark mode support
- β³ Settings screen
- β³ Empty states
- β³ Loading indicators
- β³ Error handling UI
- β³ Firebase authentication
- β³ Cloud Firestore sync
- β³ Offline-first architecture
- β³ Conflict resolution
- β³ Multi-device sync
| Component | Tests | Coverage | Status |
|---|---|---|---|
| Todo Model | 17 | 100% | β |
| HiveStorageService | 24 | 100% | β |
| TodoManager | 28 | ~95% | β |
| Total | 69 | ~98% | β |
- β Data model conversions (Todo β DTO)
- β All CRUD operations
- β Business logic (add, update, delete, toggle, filter)
- β Computed properties (counts, checks)
- β Edge cases (empty data, null values, large datasets)
- β Error scenarios (validation, not found)
See TEST_SUMMARY.md for detailed coverage report.
flutter analyzeResult: β No issues found!
Hive adapters are generated using build_runner:
# Generate once
dart run build_runner build
# Watch for changes
dart run build_runner watch
# Delete conflicting outputs
dart run build_runner build --delete-conflicting-outputs- Update Domain Model (
lib/features/todos/models/) - Update DTO (if storage schema changes)
- Run Code Generation (
dart run build_runner build) - Update Service Layer (if I/O operations needed)
- Update Manager (business logic and commands)
- Write Tests (aim for >90% coverage)
- Update Views (UI implementation)
- Run Tests (
flutter test) - Run Analyzer (
flutter analyze)
- β Always prefer editing existing files over creating new ones
- β Follow PFA layer separation (Views β Managers β Services)
- β Use Commands for state-modifying operations
- β Use watch_it for reactive UI updates
- β Write tests before implementation (TDD encouraged)
- β Keep ValueNotifiers in Managers, not Views
- β Validate in Manager layer, not Views
- β Never modify state directly, always through Commands
See rules.md for complete architecture guidelines.
Problem: Tests failing with "ValueNotifier used after disposal" Solution: Ensure proper async handling in setUp/tearDown with delays
Problem: Build runner fails
Solution: Run with --delete-conflicting-outputs flag
Problem: Hive adapter not found
Solution: Run dart run build_runner build and restart app
Problem: Import errors for generated files
Solution: Run flutter pub get then dart run build_runner build
This is a learning project following PFA architecture principles. Key areas for contribution:
- Phase 1B: Implement UI layer with
WatchingWidget - Phase 2: Add Firebase integration
- Testing: Add widget and integration tests
- Documentation: Improve code comments and examples
This project is created for educational purposes to demonstrate PFA architecture.
- Thomas Burkhart for the PFA architecture and watch_it/command_it packages
- Flutter Team for the amazing framework
- Hive developers for the fast local database
- Lines of Code: ~800 (excluding tests and generated files)
- Test Lines: ~1,100
- Test Coverage: ~98%
- Build Time: ~30s (web)
- Test Time: ~12s
- Dependencies: 8 main, 5 dev
- Implement Todo List View (Phase 1B - Step 8)
- Implement Todo Form (Phase 1B - Step 9)
- Add Navigation (Phase 1B - Step 10)
- Create Shared Widgets (Phase 1B - Step 11)
- Add Widget Tests (Phase 1B - Steps 13-14)
See plan.md for the complete roadmap.
Built with β€οΈ using Flutter and PFA Architecture
For questions or issues, refer to the documentation files in this repository.