skip to Main Content

From my understanding of MVC Comming from .Net is that in MVC the useer interacts with the View which triggers the Controller and the controller returns a new View.But the examples I find for flutter the controllers does not really return new view they only update the state which updates the UI. This pattern is more like MVVVM than MVC. So what am i missing?

How can one implement MVC in flutter?

2

Answers


  1. MVC started with Smalltalk, I believe. I learned MVC from the original ST80 image in 1982. The view paints controls, wired to the controllers, which arranges for the model to be updated. The model is being observed by the view and updates itself on changes.

    I mimic this pretty close with Riverpod, using widgets for the view, action callbacks calling notifier mutation methods as the controller, and watching the provider in the view for updates. For me, this is closer to MVC than MVVM, which nearly always introduces an unnecessary layer in Flutter, and seems not to be good match.

    Login or Signup to reply.
  2. Here we can simplify MVC (Model View Controller)

    1. Model : It is the structure of data where we can determine which values we need for this task.
    2. View : It is UI (User Interface) where only user UI is handled.
    3. Controller : It is performing communications between model and user. It can change state of UI. All logics should be written in controller.
      I recommend you to use Getx state management. Where you can easy practice and understand MVC pattern.
      Getx is a popular state management package on pub.dev. Along side with state management you can find various help full things like routing etc.
      I hope this can work for you.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search