0

I'm having confusion regarding the correct implementation of MVVM architecture in a flutter.

Does MVVM require separating just the UI calls from the UI or separating the complete logic of the widgets, even if it is to update a CheckBox?

If using setState does not raise performance issues, should we use it when following MVVM architecture?

If it is okay to have some logic inside of widgets, to what extent should we do that?

ASAD HAMEED
  • 2,296
  • 1
  • 20
  • 36

2 Answers2

0

Yes obviously , I suggest you to study Clean Architecture, Basically concept is that, You have to create ViewModel for every screen.

  1. Screen will contain all the Widgets (View)
  2. View Model will contain all functionality and variable which will be hold value which used in Screen (View)
  • If I'm using Provider for state management, do I need to create a separate controller for every screen? I currently have one controller per module. – ASAD HAMEED Oct 12 '22 at 04:21
0

It is perfectly okay for the widget to manage its state internally. It wouldn't make sense e.g. ListView not to manage its scrolling state. The same obviously applies to custom widgets.

See Differentiate between ephemeral state and app state for more information.

user18309290
  • 5,777
  • 2
  • 4
  • 22