# ViewModel scope và shared repository

> Hai màn đọc chung repository thay vì gọi nhau, màn chơi tự mở ván khi hiện lên nên điều hướng là đủ, hiệu ứng ăn mừng sống ở shell, và bảng quyết định state nào đặt ở đâu.

- URL: https://dantech.academy/courses/flutter-mobile-101/05-navigation/lesson-03-where-state-lives
- Khóa học: [Flutter Mobile 101](https://dantech.academy/courses/flutter-mobile-101.md)
- Module: Kiến Trúc Màn Hình
- Thời lượng: 16 phút
- Độ khó: beginner
- Truy cập: Dành cho học viên

## Mục tiêu

- Giải thích được kỹ thuật hai màn cùng đọc từ một nguồn bền hơn cả hai, thay vì tham chiếu lẫn nhau
- Dùng được khung quyết định: state này sống theo màn, theo app, hay trong repository

## Nội dung bài học

1. Mỗi Màn Một ViewModel, Vậy Chúng Nói Chuyện Kiểu Gì
2. ResultViewModel Đọc Từ Repository, Không Từ GameViewModel
3. Màn Chơi Hiện Lên Là Ván Bắt Đầu
4. CelebrationController Sống Ở Shell
5. Khung Quyết Định: Cái Gì Đặt Ở Đâu

## Học cùng AI agent

Toàn bộ bài học dành cho học viên của khóa. Học viên mở bài trên web và bấm nút **Markdown** để copy toàn bài, rồi dán vào Claude, ChatGPT, Cursor hoặc agent bạn đang dùng. Nhanh hơn: tạo token ở `/profile/ai-agents` và agent đọc bài trực tiếp qua MCP.

- [Đăng ký khóa học](https://dantech.academy/flutter-mobile-101/checkout)

---

- Bài trước: [AppShell, ValueKey và PopScope](https://dantech.academy/courses/flutter-mobile-101/05-navigation/lesson-02-appshell-and-transitions.md)
- Bài tiếp theo: [SharedPreferencesAsync và repository pattern](https://dantech.academy/courses/flutter-mobile-101/06-full-app/lesson-01-local-persistence-repository.md)
