Model-View-Controller in the context of Flutter
Model View Controller is an Architecture. Let's break this word by word to understand this Architecture.
View: View in easy words means "Nazara", which anyone can see. In Software Development, view is the User Interface (UI), that end-users see and interact with. The view consists of widgets or elements/components, that users interact.
Models: The Model represents the internal data shown through the UI. Although View and Model do not interact with each other directly. So here comes the role of Controller.
Controller: The Controller is responsible for manipulating the Model (raw Data) according to the changes in View such as when a user adds any information or clicks a button or interacts with any Element visible.
The Controller handles interaction by updating the view or making changes to the model as needed.
Suppose the UI (View) shows a list of fruits and the user selects one fruit whereas the model contains the details of all listed fruits such as season, name, taste, prize, benefits, etc.
On selecting the fruit, user interacts with UI (View), and this interaction is sensed by controller and controller inform Model about the interaction then controller fetches the detail of Fruits to the UI (View) and screen shows the details of the selected Fruit.
Recommended by LinkedIn
Model-View-Controller is an Architectural design pattern. This pattern separates the UI and Logic of the application making the code readable, organized, and modularized. Modularize means it separates the distinct components of an application and helps our application look more professionally handled (from the developer's perspective).
The controller acts as an intermediary between the Model and View. The Model's data can be shown to the user in different ways by using different UI elements. It doesn't affect the Model.
Model is like, writing once and using multiple times wherever you want. Its data is hidden from the user (View) and only the controller can interact with both Model and View. The Model encapsulates data.
This is a brief introduction to MVC, Model-View-Controller focuses on its use in flutter development.
Drop a comment if you use MVC or a similar pattern in your projects. I would love to hear about your approach!
#flutter #designPattern #MVC #MVVM #MVCArchitecture #softwaredevelopment #MVC
Soonha Soomro This is such a well-written article! Your explanation of MVC in Flutter is clear and makes a complex topic easy to understand. Thank you for sharing this valuable resource. Great work!
Beautiful explanation Soonah appreciated 👏👏