What is the practical difference between MVVM and MVC architecture in flutter [closed]

I have read many articles regarding this but haven’t found any good answer. Can someone give me references to any projects on github or any articles which can explain it clearly?

I tried to found a good article to learn the difference between MVVM and MVC architecture in flutter. But none of them were able to clearly explain it. I watched youtube videos as well but still the difference is not clear.

1

MVC (Model-View-Controller) and MVVM (Model-View-ViewModel) are the architectures used in Flutter to manage the data flow.

MVC (Model-View-Controller) in Flutter:

  • Model: Manages the data and business logic of the application.
  • View: The UI part that displays data to the user.
  • Controller: Intermediates between the Model and the View. It receives input from the View, processes it (often updating the Model), and updates the View accordingly.

MVVM (Model-View-ViewModel) in Flutter:

  • Model: Same as in MVC, it holds the business logic and data.
  • View: The UI part that displays data to the user.
  • ViewModel: An intermediary that handles all the logic and communicates with the Model. The View listens for changes in the ViewModel and reacts accordingly).

In Simple words,
In MVC, the Controller acts as a layer that manages the state and updates the View
but in MVVM, ViewModel acts as a layer that manages the state and uses a notifier to update the View.

Here’s a comparison between MVC and MVVM in Flutter:

Aspect MVC (Model-View-Controller) MVVM (Model-View-ViewModel)
Role of Controller/ViewModel The Controller handles user input, updates the Model, and controls the View. The ViewModel holds the state and logic, interacts with the Model, and updates the View through state management.
View-Controller/ ViewModel Relationship The View and Controller are tightly coupled, as the StatefulWidget typically handles both UI and logic. The View and ViewModel are loosely coupled, with the View observing the ViewModel for changes in a reactive manner.
Data Flow Data flows from the Model to the Controller, which manually updates the View. The ViewModel manages the data, and the View automatically listens for changes in the ViewModel.
State Management State is managed inside the StatefulWidget, often leading to tightly bound logic and UI, which makes separation of concerns more difficult. State is handled by the ViewModel using state management techniques (Provider, Riverpod, GetX), keeping logic out of the View.
Separation of Concerns Limited separation between the UI and business logic due to the StatefulWidget acting as both controller and view. Clear separation of concerns. The ViewModel manages all the logic, and the View is only responsible for UI rendering.
UI Update Mechanism The Controller has to manually update the View when the Model changes, typically by calling setState() in StatefulWidget. The View listens to changes in the ViewModel, which handles state updates automatically using notifyListeners() or streams, depending on the method.
Testability Harder to test since logic is mixed within the UI (view). Easier to test as the ViewModel contains the business logic, separated from the UI.
Scalability Suitable for small to medium-sized projects. Scales well for larger projects since the logic and state are separated, making it easier to manage complex UIs and features.
State & Data Binding The View does not automatically reflect changes in the Model. The Controller has to manually trigger UI updates. The View automatically reflects changes in the ViewModel, which manages the state and triggers UI updates.
When to Use Best suited for smaller apps. Better suited for larger, more complex apps.
Example Example for MVC architecture Example for MVVM architecture

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật